L
LyndsyJo
(This is a case of being told, "Make this database, make it do this, this,
and this, and do it without any real training.")
I have a tiny table called "Color Table", and a main table called "Item
Table". "Item Table" has a field called "Color" that looks up the values in
"Color Table". In my form, if the color I need is not in the list, I want to
type the value and have it add it to my "Color Table" so that it is available
as a choice on my form for future records.
I have spent a couple hours looking through the discussion groups here, and
have followed several links that people have posted to sites that list Visual
Basic code to assist me in doing this. However, I know *nothing* about
Visual Basic, and while I tried several ways of changing the info in the
codes to match my database, I just don't know enough to make it work. Can
anyone give me a suggestion on how to make this work?
Here's the code I got from http://www.pacificdb.com.au/MVP/Code/NIL.htm:
Private Sub Combo0_NotInList(NewData As String, Response As Integer)
Dim db As Database
Set db = CurrentDb
'Add the new value to the field
db.Execute "INSERT INTO tblMyTable (SomeField) VALUES (""" & NewData &
""")", dbFailOnError
'Tell Access you've added the value
Response = acDataErrAdded
db.Close
Set db = Nothing
End Sub
And this is what I came up with:
Private Sub Color_NotInList(NewData As String, Response As Integer)
Dim db As Database
Set db = CurrentDb
'Add the new value to the field
db.Execute "INSERT INTO [Colors Table] (Color) VALUES (""" & NewData &
""")", dbFailOnError
'Tell Access you've added the value
Response = acDataErrAdded
db.Close
Set db = Nothing
End Sub
What am I doing wrong, or not doing at all? Please be gentle! Thank you.
and this, and do it without any real training.")
I have a tiny table called "Color Table", and a main table called "Item
Table". "Item Table" has a field called "Color" that looks up the values in
"Color Table". In my form, if the color I need is not in the list, I want to
type the value and have it add it to my "Color Table" so that it is available
as a choice on my form for future records.
I have spent a couple hours looking through the discussion groups here, and
have followed several links that people have posted to sites that list Visual
Basic code to assist me in doing this. However, I know *nothing* about
Visual Basic, and while I tried several ways of changing the info in the
codes to match my database, I just don't know enough to make it work. Can
anyone give me a suggestion on how to make this work?
Here's the code I got from http://www.pacificdb.com.au/MVP/Code/NIL.htm:
Private Sub Combo0_NotInList(NewData As String, Response As Integer)
Dim db As Database
Set db = CurrentDb
'Add the new value to the field
db.Execute "INSERT INTO tblMyTable (SomeField) VALUES (""" & NewData &
""")", dbFailOnError
'Tell Access you've added the value
Response = acDataErrAdded
db.Close
Set db = Nothing
End Sub
And this is what I came up with:
Private Sub Color_NotInList(NewData As String, Response As Integer)
Dim db As Database
Set db = CurrentDb
'Add the new value to the field
db.Execute "INSERT INTO [Colors Table] (Color) VALUES (""" & NewData &
""")", dbFailOnError
'Tell Access you've added the value
Response = acDataErrAdded
db.Close
Set db = Nothing
End Sub
What am I doing wrong, or not doing at all? Please be gentle! Thank you.