C
CJ
Hi groupies:
I am working with Not In List and having some trouble with the order of
operations and my code. I can almost get it to work, but it is awkward and
not efficient.
Problems are:
#1 I can not get the combo box to update without physically running the query.
#2 When frmContacts opens up, it does not find the matching contact ID. It
doesn't show any contacts at all, even though they are in the query.
Private Sub lngContactID_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = strMsg & " Add " & NewData & " to the list?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "NEW CONTACT") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblContacts", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!strContactFirst = NewData
rs.Update
PROBLEM #1
DoCmd.OpenQuery "qryContacts"
DoCmd.Close acQuery, "qryContacts"
PROBLEM #2
DoCmd.OpenForm "frmContacts", acNormal, , "lngContactID" =
Forms!frmQuotes!lngContactID
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
End Sub
Thanks for the thoughts and brain waves
CJ
I am working with Not In List and having some trouble with the order of
operations and my code. I can almost get it to work, but it is awkward and
not efficient.
Problems are:
#1 I can not get the combo box to update without physically running the query.
#2 When frmContacts opens up, it does not find the matching contact ID. It
doesn't show any contacts at all, even though they are in the query.
Private Sub lngContactID_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = strMsg & " Add " & NewData & " to the list?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "NEW CONTACT") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblContacts", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!strContactFirst = NewData
rs.Update
PROBLEM #1
DoCmd.OpenQuery "qryContacts"
DoCmd.Close acQuery, "qryContacts"
PROBLEM #2
DoCmd.OpenForm "frmContacts", acNormal, , "lngContactID" =
Forms!frmQuotes!lngContactID
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
End Sub
Thanks for the thoughts and brain waves
CJ