M
Monet 138
I did a search but didn't find anything that solved the issue. I copied the
sample code listed in multiple posts and put it in a form 4 times (once for
each combo box that needed it). It works great for the first two combo boxes
and only sort of worked for the other two. I created a single secondary Form
to test and make sure it worked on the first combo box. Then I simply copied
that form and carefully renamed the two fields, linked table, and event
coding to the correct names.
The problem is that the NewData doesn't load the info into the newly opened
form when fired for either of the last two combo boxes. I added NewData to
the Watch list and put in some breakpoints for each combo box. It does show
up in the Watch list with the correct value at the correct point for all four
combo boxes, but the info never appears in the secondary form.
Here is the code as it shows in the VB window. Thanks in advance for the
help.
Private Sub Area_1_NotInList(NewData As String, Response As Integer)
Dim NewCategory As Integer, Title As String, MsgDialog As Integer
' Display message box asking if user wants to add a new entry.
NewCategory = MsgBox("Do you want to add a new area?", 36, "Area Not In
List")
If NewCategory = 6 Then ' User chose Yes.
' Remove new item from combo box so control can be requeried when
user returns to form.
DoCmd.Save
AREA_1.Undo
' Open NewArea1 form and set the Area value.
DoCmd.OpenForm "sub_NewArea1", , , , acFormAdd
Forms!sub_NewArea1!Area = NewData
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
If NewCategory = 7 Then ' User chose No.
' Clear the text box
AREA_1.Undo
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
End Sub
Private Sub Area_2_NotInList(NewData As String, Response As Integer)
Dim NewCategory As Integer, Title As String, MsgDialog As Integer
' Display message box asking if user wants to add a new entry.
NewCategory = MsgBox("Do you want to add a new area?", 36, "Area Not In
List")
If NewCategory = 6 Then ' User chose Yes.
' Remove new item from combo box so control can be requeried when
user returns to form.
DoCmd.Save
AREA_2.Undo
' Open NewArea2 form and set the Area value.
DoCmd.OpenForm "sub_NewArea2", , , , acFormAdd
Forms!sub_NewArea2!Area = NewData
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
If NewCategory = 7 Then ' User chose No.
' Clear the text box
AREA_2.Undo
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
End Sub
Private Sub STREET_1_NotInList(NewData As String, Response As Integer)
Dim NewCategory As Integer, Title As String, MsgDialog As Integer
' Display message box asking if user wants to add a new entry.
NewCategory = MsgBox("Do you want to add a new street?", 36, "Street Not
In List")
If NewCategory = 6 Then ' User chose Yes.
' Remove new item from combo box so control can be requeried when
user returns to form.
DoCmd.Save
STREET_1.Undo
' Open NewStreet1 form and set the Street value.
DoCmd.OpenForm "sub_NewStreet1", , , , acFormAdd
Forms!sub_NewStreet1!Street = NewData
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
If NewCategory = 7 Then ' User chose No.
' Clear the text box
STREET_1.Undo
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
End Sub
Private Sub STREET_2_NotInList(NewData As String, Response As Integer)
Dim NewCategory As Integer, Title As String, MsgDialog As Integer
' Display message box asking if user wants to add a new entry.
NewCategory = MsgBox("Do you want to add a new street?", 36, "Street Not
In List")
If NewCategory = 6 Then ' User chose Yes.
' Remove new item from combo box so control can be requeried when
user returns to form.
DoCmd.Save
STREET_2.Undo
' Open NewStreet form and set the Street value.
DoCmd.OpenForm "sub_NewStreet2", , , , acFormAdd
Forms!sub_NewStreet2!Street = NewData
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
If NewCategory = 7 Then ' User chose No.
' Clear the text box
STREET_2.Undo
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
End Sub
sample code listed in multiple posts and put it in a form 4 times (once for
each combo box that needed it). It works great for the first two combo boxes
and only sort of worked for the other two. I created a single secondary Form
to test and make sure it worked on the first combo box. Then I simply copied
that form and carefully renamed the two fields, linked table, and event
coding to the correct names.
The problem is that the NewData doesn't load the info into the newly opened
form when fired for either of the last two combo boxes. I added NewData to
the Watch list and put in some breakpoints for each combo box. It does show
up in the Watch list with the correct value at the correct point for all four
combo boxes, but the info never appears in the secondary form.
Here is the code as it shows in the VB window. Thanks in advance for the
help.
Private Sub Area_1_NotInList(NewData As String, Response As Integer)
Dim NewCategory As Integer, Title As String, MsgDialog As Integer
' Display message box asking if user wants to add a new entry.
NewCategory = MsgBox("Do you want to add a new area?", 36, "Area Not In
List")
If NewCategory = 6 Then ' User chose Yes.
' Remove new item from combo box so control can be requeried when
user returns to form.
DoCmd.Save
AREA_1.Undo
' Open NewArea1 form and set the Area value.
DoCmd.OpenForm "sub_NewArea1", , , , acFormAdd
Forms!sub_NewArea1!Area = NewData
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
If NewCategory = 7 Then ' User chose No.
' Clear the text box
AREA_1.Undo
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
End Sub
Private Sub Area_2_NotInList(NewData As String, Response As Integer)
Dim NewCategory As Integer, Title As String, MsgDialog As Integer
' Display message box asking if user wants to add a new entry.
NewCategory = MsgBox("Do you want to add a new area?", 36, "Area Not In
List")
If NewCategory = 6 Then ' User chose Yes.
' Remove new item from combo box so control can be requeried when
user returns to form.
DoCmd.Save
AREA_2.Undo
' Open NewArea2 form and set the Area value.
DoCmd.OpenForm "sub_NewArea2", , , , acFormAdd
Forms!sub_NewArea2!Area = NewData
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
If NewCategory = 7 Then ' User chose No.
' Clear the text box
AREA_2.Undo
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
End Sub
Private Sub STREET_1_NotInList(NewData As String, Response As Integer)
Dim NewCategory As Integer, Title As String, MsgDialog As Integer
' Display message box asking if user wants to add a new entry.
NewCategory = MsgBox("Do you want to add a new street?", 36, "Street Not
In List")
If NewCategory = 6 Then ' User chose Yes.
' Remove new item from combo box so control can be requeried when
user returns to form.
DoCmd.Save
STREET_1.Undo
' Open NewStreet1 form and set the Street value.
DoCmd.OpenForm "sub_NewStreet1", , , , acFormAdd
Forms!sub_NewStreet1!Street = NewData
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
If NewCategory = 7 Then ' User chose No.
' Clear the text box
STREET_1.Undo
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
End Sub
Private Sub STREET_2_NotInList(NewData As String, Response As Integer)
Dim NewCategory As Integer, Title As String, MsgDialog As Integer
' Display message box asking if user wants to add a new entry.
NewCategory = MsgBox("Do you want to add a new street?", 36, "Street Not
In List")
If NewCategory = 6 Then ' User chose Yes.
' Remove new item from combo box so control can be requeried when
user returns to form.
DoCmd.Save
STREET_2.Undo
' Open NewStreet form and set the Street value.
DoCmd.OpenForm "sub_NewStreet2", , , , acFormAdd
Forms!sub_NewStreet2!Street = NewData
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
If NewCategory = 7 Then ' User chose No.
' Clear the text box
STREET_2.Undo
' Continue without displaying default error message.
Response = DATA_ERRCONTINUE
End If
End Sub