Hello Everyone.
I have a error that I have tried everything to fix and can't seem to find the answer.
I have 2 combobox, when you select a value in the first box it changes the values in the other box. All this is working.
I achieved this by creating a query and having the second combobox grab its data from the query.
I want to be able to add new values to the combobox just by typing on them, so I created a Not in List event. for each box.
For the first box it is working, but for the second box I get an error saying:
"Number of query values and destination fields are not the same"
for the second one, I need to add to the table not only the new value but also the PK from the first ComboBox
here is the code for the second box not in list event:
Code:
Private Sub Add_Weight_Location_NotInList(NewData As String, Response As Integer)
Answer = MsgBox("add " & NewData & " as a new Location?", vbYesNo, "Location doesn't exist")
If Answer = vbYes Then
SQLStmt = "Insert into Weight_Locations(Locations, CategoryID) " & _
" VALUES (" & NewData & " & '" & Me.Add_Weight_cat & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL SQLStmt
Response = acDataErrAdded
DoCmd.SetWarnings True
Else
Response = acDataErrContinue
End If
End Sub
I also attached the file
Hope someone can help me out with this, I have been around this one for hours now.
Thanks so much