I have a form to enter bank info, and a combo on this form (cbo1) lists bank directors. The combobox is based on tbl_Directors containing three fields: DirectorID (AutoNumber), LastName, and FirstName. Cbo1 has two columns, DirectorID (the bound column, not shown) and an expression that displays the directors’ full names by combining LastName and FirstName.
Users add new directors regularly, so I am using a NotInList event for cbo1. More than one field in tbl_Directors will be updated, so the NotInList code should bring up the form to enter directors (frm_Directors). Once entered, I want new directors to show up on cbo1 in the original form.
My Not in List code for cbo1 looks like this:
Private Sub cbo1_NotInList(NewData As String, Response As Integer)
Dim strTask As String
Dim Msg As String
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
' Message prompt for entries not in list.
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add them?
If MsgBox = (Msg, vbQuestion + vbYesNo) = vbYes
Then
DoCmd.OpenForm "frm_ Directors", , , , acAdd, acDialog, NewData
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
My OnLoad property of frm_Directors contains this code:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me![DirectorID] = Me.OpenArgs
End If
End Sub
Access throws me a compile error for the line
MsgBox = (Msg, vbQuestion + vbYesNo) = vbYes
The debugger highlights the comma after Msg and says “Expected: ).” How am I erring in my code? (Likely, it’s in more than this one place).
Thanks always for your help. J
Users add new directors regularly, so I am using a NotInList event for cbo1. More than one field in tbl_Directors will be updated, so the NotInList code should bring up the form to enter directors (frm_Directors). Once entered, I want new directors to show up on cbo1 in the original form.
My Not in List code for cbo1 looks like this:
Private Sub cbo1_NotInList(NewData As String, Response As Integer)
Dim strTask As String
Dim Msg As String
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
' Message prompt for entries not in list.
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add them?
If MsgBox = (Msg, vbQuestion + vbYesNo) = vbYes
Then
DoCmd.OpenForm "frm_ Directors", , , , acAdd, acDialog, NewData
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
My OnLoad property of frm_Directors contains this code:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me![DirectorID] = Me.OpenArgs
End If
End Sub
Access throws me a compile error for the line
MsgBox = (Msg, vbQuestion + vbYesNo) = vbYes
The debugger highlights the comma after Msg and says “Expected: ).” How am I erring in my code? (Likely, it’s in more than this one place).
Thanks always for your help. J