Inserting new argument to table through search form of another table

Posted by owca on Stack Overflow See other posts from Stack Overflow or by owca
Published on 2010-06-15T22:37:04Z Indexed on 2010/06/15 22:52 UTC
Read the original article Hit count: 206

Filed under:
|
|

In my database I have a form for searching products (fields : id, name, manufacturer_id[set to display manufacturer's name], category_id, price). I would like to have the ability of adding manufacturers through this form. So I've created vba script but it does not work. Still when I enter new name it gives me prompt to "Select element from the list". What am I doing wrong ?

Private Sub manufacturer_id_NotInTheList(NewData As String, Response As Integer)
Dim strSQL As String, strInfo As String
strInfo = "Manufacturer " & NewData & " is not on the list." & vbCrLf & "Add?"
If MsgBox(strInfo, vbYesNo + vbQuestion, "Element not on the list") = vbYes Then
strSQL = "INSERT INTO manufacturer (name, country, id_distributor) VALUES ('" & NewData & "','Undefined', '0');"
DoCmd.SetWarnings (False)
DoCmd.RunSQL strSQL
Response = acDataErrAdded
Else
Response = acDataErrContinue
NewData = ""
Me.manufacturer_id.Text = ""
End If
End Sub

© Stack Overflow or respective owner

Related posts about ms-access

Related posts about vba