P
PHisaw
Hi,
I have two combo boxes on a form - CustomerNameCombo and ContactNameCombo.
Originally, it was set up to list names from drop down for both boxes. When
the name wasn't in the list, another form would automatically open with the
new typed name entered in the name field and then all other info would be
added. When user closed pop up form, the info was added to the main form.
Then I decided to limit the contact names to those related to each customer
name.
The pop up form opens when new entry is typed, I can enter all other info,
but when I close this form, I get an error message that the value is not in
the list. Also, on this line of code
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd, acDialog, NewData
I get a Compile Error Msg - "Argument Not Optional".
All code associated with each combo box is listed below. If anyone can help
resolve this, it will be greatly appreciated. I've searched previous posts,
but can't find any fixes.
Private Sub ContactNameCombo_AfterUpdate()
Me.Requery
End Sub
Private Sub ContactNameCombo_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_ContactNameCombo_NotInList
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "fContactList"
stLinkCriteria = "[ContactName]=" & "'" & Me.ContactNameCombo & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd, acDialog, NewData
Response = acDataErrAdded
Exit_ContactNameCombo_NotInList:
Exit Sub
Err_ContactNameCombo_NotInList:
MsgBox Err.Description
Resume Exit_ContactNameCombo_NotInList
End Sub
Private Sub CustomerNameCombo_AfterUpdate()
Me.ContactNameCombo.Requery
Thanks in advance for any help!
Pam
I have two combo boxes on a form - CustomerNameCombo and ContactNameCombo.
Originally, it was set up to list names from drop down for both boxes. When
the name wasn't in the list, another form would automatically open with the
new typed name entered in the name field and then all other info would be
added. When user closed pop up form, the info was added to the main form.
Then I decided to limit the contact names to those related to each customer
name.
The pop up form opens when new entry is typed, I can enter all other info,
but when I close this form, I get an error message that the value is not in
the list. Also, on this line of code
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd, acDialog, NewData
I get a Compile Error Msg - "Argument Not Optional".
All code associated with each combo box is listed below. If anyone can help
resolve this, it will be greatly appreciated. I've searched previous posts,
but can't find any fixes.
Private Sub ContactNameCombo_AfterUpdate()
Me.Requery
End Sub
Private Sub ContactNameCombo_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_ContactNameCombo_NotInList
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "fContactList"
stLinkCriteria = "[ContactName]=" & "'" & Me.ContactNameCombo & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd, acDialog, NewData
Response = acDataErrAdded
Exit_ContactNameCombo_NotInList:
Exit Sub
Err_ContactNameCombo_NotInList:
MsgBox Err.Description
Resume Exit_ContactNameCombo_NotInList
End Sub
Private Sub CustomerNameCombo_AfterUpdate()
Me.ContactNameCombo.Requery
Thanks in advance for any help!
Pam