S
SAC
I'm running code in the not in list event of a combobox to add a row and
then I am attempting to lookup a record based on the added row. The adding
of the row works fine, but not the looking up of the record. Here's the
code I'm using:
Response = acDataErrContinue
Dim intAnswer As Integer
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim strOldValue As String
Dim strName As String
Dim varCost As Variant
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblOrg", dbOpenDynaset) 'Open the recordset
for the combobox table
intAnswer = MsgBox("Add " & NewData & " to Associations?", vbQuestion +
vbYesNo) 'Caption of ComboBox
If intAnswer = vbYes Then
With rst
.AddNew
!Organization = NewData
!Type = "Association"
'ID is autonumbered and a primary key field
.Update
End With
Response = acDataErrAdded ' Requery the combo box list.
************** Thought the new record would be in the combo box at this
point ******************
'************* Here's the line that doesn't work:
Me.frmBookingShowsAssociations.Form.Recordset.FindFirst "ID = " &
Me.cboAssociationLookup
'******************************************************************************
Else
Me.Undo
Response = acDataErrContinue ' Require the user to select
' an existing item
End If
Thanks for your help.
then I am attempting to lookup a record based on the added row. The adding
of the row works fine, but not the looking up of the record. Here's the
code I'm using:
Response = acDataErrContinue
Dim intAnswer As Integer
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim strOldValue As String
Dim strName As String
Dim varCost As Variant
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblOrg", dbOpenDynaset) 'Open the recordset
for the combobox table
intAnswer = MsgBox("Add " & NewData & " to Associations?", vbQuestion +
vbYesNo) 'Caption of ComboBox
If intAnswer = vbYes Then
With rst
.AddNew
!Organization = NewData
!Type = "Association"
'ID is autonumbered and a primary key field
.Update
End With
Response = acDataErrAdded ' Requery the combo box list.
************** Thought the new record would be in the combo box at this
point ******************
'************* Here's the line that doesn't work:
Me.frmBookingShowsAssociations.Form.Recordset.FindFirst "ID = " &
Me.cboAssociationLookup
'******************************************************************************
Else
Me.Undo
Response = acDataErrContinue ' Require the user to select
' an existing item
End If
Thanks for your help.