G
Guest
I am trying to add values to my combo box called Patterns on the fly. My
problem is the table of Patterns I am adding to requires both a PatternName
and a Manufacturer as primary fields for each record.
I have been using the code below supplied by Al Campagna.
Private Sub PatternName_NotInList(NewData As String, Response As Integer)
Dim sqlAddPattern As String, UserResponse As Integer
Beep
UserResponse = MsgBox("Do you want to add this Pattern to the list?", vbYesNo)
If UserResponse = vbYes Then
sqlAddPattern = "Insert Into Patterns ([PatternName]) values ('" &
NewData & "')"
CurrentDb.Execute sqlAddPattern, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
My first field on the form is manufacturer. Its drop down list is fairly
complete, and if not the above code works to add a new manufacturer to the
manufacturers table. Next I tab to the PatternName ComboBox. I get to the
point where it is ready to add the new name to the list, but if I try to
proceed I get a run time error 3058 primary or index field can not contain a
null value. The code line: CurrentDb.Execute sqlAddPattern, dbFailOnError is
highlighted
How can I modify the code so the manufacturer value i selected is also added
by the code?
Thanks so much
problem is the table of Patterns I am adding to requires both a PatternName
and a Manufacturer as primary fields for each record.
I have been using the code below supplied by Al Campagna.
Private Sub PatternName_NotInList(NewData As String, Response As Integer)
Dim sqlAddPattern As String, UserResponse As Integer
Beep
UserResponse = MsgBox("Do you want to add this Pattern to the list?", vbYesNo)
If UserResponse = vbYes Then
sqlAddPattern = "Insert Into Patterns ([PatternName]) values ('" &
NewData & "')"
CurrentDb.Execute sqlAddPattern, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
My first field on the form is manufacturer. Its drop down list is fairly
complete, and if not the above code works to add a new manufacturer to the
manufacturers table. Next I tab to the PatternName ComboBox. I get to the
point where it is ready to add the new name to the list, but if I try to
proceed I get a run time error 3058 primary or index field can not contain a
null value. The code line: CurrentDb.Execute sqlAddPattern, dbFailOnError is
highlighted
How can I modify the code so the manufacturer value i selected is also added
by the code?
Thanks so much