Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Entering 2 values into a table, in the same record? 3

Status
Not open for further replies.

ScorpioX

MIS
Apr 30, 2003
63
US
Hi all,
Need a little help here. This has been driving me nuts, not even sure it can work. I look to be real close with it however, so I am thinking it might.
I have a form with two combo boxes on it. i.e Type and Model, by choosing a Type, certain Models will showup. All works well until a new Model needs to be entered. Both Combo's are stored in a table called tblModelA, with only two fields Type and Model. I am using code to prompt the user if they want to add the Model to the list if it is not already there. Were I run into trouble is trying to populate the Type field, while creating the new Model into a new record. The code I am using is below. I can not figure out were I am going wrong, it keeps failing on the CurrentDB.execute line. Anyone have any ideas?


Private Sub ModelID_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Model...")
If i = vbYes Then
strSQL = "Insert Into tblModelA ([Model],[Type]) values ('" & NewData & "') & ('" & Me.Type.Value & "')"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub

Thanks in advance,
ScorpioX
 
strSQL = "Insert Into tblModelA ([Model],[Type]) values ('" & NewData & "','" & Me.Type.Value & "')"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH,
Awesome,worked like a charm. Thank you very much!
Gave you a star.
Thanks again,
ScorpioX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top