G
Guest
I am currently trying to add this code to the after update of my combo box -
What I want the code to do is allow the user to use a name that is not listed
in the Reroute Contacts table - and then they can have the option to add the
name to the original table. I don't know if I am explaining this very well
or not. Here is the code that I have - when I try to run the code it stops
at the End Sub part. I am not sure what I am doing wrong. Any help would be
greatly appreciated.
Private Sub cboRerouteContacts_AfterUpdate()
Dim intAnswer As Integer
intAnswer = MsgBox("The Reroute Contact " & Chr(34) & strNewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNoCancel, "Reroute Contacts")
Dim strSQL As String
If Statement Then
If vbYes Then
' Allow entry and add new item to the list
strSQL = "INSERT INTO Reroute Contacts ([Reroute Contacts]) " & _
"VALUES ('" & strNewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
blnNewListItem = True
MsgBox "The new contact has been added to the list." _
, vbInformation, "Reroute Contacts"
If vbNo Then
'Allow entry but do not add item to list
'No action necessary
If vbCancel Then
'Do not allow entry
MsgBox "Please choose a contact from the list.", _
vbExclamation, "Reroute Contacts"
Me.cboRerouteContacts.Undo
Me.cboRerouteContacts.Dropdown
Cancel = True
End If
End If
End If
End Sub
What I want the code to do is allow the user to use a name that is not listed
in the Reroute Contacts table - and then they can have the option to add the
name to the original table. I don't know if I am explaining this very well
or not. Here is the code that I have - when I try to run the code it stops
at the End Sub part. I am not sure what I am doing wrong. Any help would be
greatly appreciated.
Private Sub cboRerouteContacts_AfterUpdate()
Dim intAnswer As Integer
intAnswer = MsgBox("The Reroute Contact " & Chr(34) & strNewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNoCancel, "Reroute Contacts")
Dim strSQL As String
If Statement Then
If vbYes Then
' Allow entry and add new item to the list
strSQL = "INSERT INTO Reroute Contacts ([Reroute Contacts]) " & _
"VALUES ('" & strNewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
blnNewListItem = True
MsgBox "The new contact has been added to the list." _
, vbInformation, "Reroute Contacts"
If vbNo Then
'Allow entry but do not add item to list
'No action necessary
If vbCancel Then
'Do not allow entry
MsgBox "Please choose a contact from the list.", _
vbExclamation, "Reroute Contacts"
Me.cboRerouteContacts.Undo
Me.cboRerouteContacts.Dropdown
Cancel = True
End If
End If
End If
End Sub