The follows I found from forum here to add Newdata(customer name), which is not in combo box list, to the rowsource table. combo82_notInlist is working well, but error occurs in "Me![Combo82]" under Combo82_AfterUpdate as access alerts.
Please kindly help to solve this error and provide me with an example to pop up the form of rowsource focusing on the Newdata to fill other data, such as customer's telephone No., fax No. etc. after Newdata added
Dim blnRecordAdded As Boolean
Private Sub Combo82_AfterUpdate()
Dim rst As Recordset
' If a new record was just added, requery the form
If blnRecordAdded Then
Me.Requery
blnRecordAdded = False
End If
' Find the record that matches the control.
Set rst = Me.RecordsetClone
rst.FindFirst "[MembershipID] = " & Me![Combo82] & ""
Me.Bookmark = rst.Bookmark
' Optional - position the cursor in the first field
' to be entered as a convenience for the user
FirstName.SetFocus
End Sub
Private Sub Combo82_NotInList(NewData As String, Response As Integer)
If MsgBox("Customer not found. Add new customer?", vbYesNo Or vbQuestion) = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblMain (MembershipID) " _
& "VALUES('" & NewData & "')"
DoCmd.SetWarnings True
blnRecordAdded = True
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
Thank you very much for your kind assistance
Please kindly help to solve this error and provide me with an example to pop up the form of rowsource focusing on the Newdata to fill other data, such as customer's telephone No., fax No. etc. after Newdata added
Dim blnRecordAdded As Boolean
Private Sub Combo82_AfterUpdate()
Dim rst As Recordset
' If a new record was just added, requery the form
If blnRecordAdded Then
Me.Requery
blnRecordAdded = False
End If
' Find the record that matches the control.
Set rst = Me.RecordsetClone
rst.FindFirst "[MembershipID] = " & Me![Combo82] & ""
Me.Bookmark = rst.Bookmark
' Optional - position the cursor in the first field
' to be entered as a convenience for the user
FirstName.SetFocus
End Sub
Private Sub Combo82_NotInList(NewData As String, Response As Integer)
If MsgBox("Customer not found. Add new customer?", vbYesNo Or vbQuestion) = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblMain (MembershipID) " _
& "VALUES('" & NewData & "')"
DoCmd.SetWarnings True
blnRecordAdded = True
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
Thank you very much for your kind assistance