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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT into with variable ?? 1

Status
Not open for further replies.

h3lm3t

Technical User
May 27, 2003
16
0
0
GB
Hi there I need help with an insert into statement, i have a variable that i want to put into a table.

The variable has value, i checked in debug, i cant see the error, it passes the vb syntax error handler, but gets stopped at runtime.

manuID is the variable
tblStock has 5 attributes

DoCmd.RunSQL "INSERT INTO [tblStock].[fkManufacturer ID] VALUES " & (manuID) & " WHERE [tblStock].[StockID] = [Forms]![frmStock]![StockID];"

[Forms]![frmStock]![StockID] is the current active from where the command is called.

Thanx in advance for any and all help.

regard
h3lm3t
 
H3lm3t,

The general format of an SQL insert statement is:

Insert into tablename (field1, field2, field3)
values (value1, value2, value3)

so your query becomes:

DoCmd.RunSQL "INSERT INTO [tblStock] ([fkManufacturer ID], stockID) VALUES (" & manuID & "," & [Forms]![frmStock]![StockID] & "')"

You will need to put apostrophes around any variable that is going into a text field and hashes around any date/time data.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top