tonikaram
asked on
sql code to INSERT a row to a table in SQL server?
I have an access form with a few text fields, and a button.
Once this button is clicked, I would like to insert to a table on my sql server a row with thvalues picked up from the few text fields places above that button.
This code is not working:
CurrentDb.Execute "INSERT into dbo_tblLiveActions values (Ref,Action_ID,Person,Acti onDate,0)"
It is saying "Too few parameters. Expected 4."
thanks
Once this button is clicked, I would like to insert to a table on my sql server a row with thvalues picked up from the few text fields places above that button.
This code is not working:
CurrentDb.Execute "INSERT into dbo_tblLiveActions values (Ref,Action_ID,Person,Acti
It is saying "Too few parameters. Expected 4."
thanks
Ok, just thought, it might not be tthe SQL
Try DoCmd.RunSQL
Try DoCmd.RunSQL
By the way, has your table got AutoNumber?
If so then use the INSERT INTO TABLE (fields) VALUES (values)
this bypasses autonumber - dont worry a number is still generated
If so then use the INSERT INTO TABLE (fields) VALUES (values)
this bypasses autonumber - dont worry a number is still generated
ASKER
it worked, but now it asks me for every row:
You are about to append 1 row(s). Once you click Yes, you can't use the Undo command to reverse the changes. Are you sure you want to append the selected rows?
since it is an SQL server. How do I remove that?
You are about to append 1 row(s). Once you click Yes, you can't use the Undo command to reverse the changes. Are you sure you want to append the selected rows?
since it is an SQL server. How do I remove that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The INSERT statement must match the fields in the database defintion
Alternatively if you do not want to specify all the fields you can specify what fields to insert into
INSERT INTO TABLE (FieldDef1, FieldDef2...) VALUES (FieldValue1, FieldValue2, ...)