Jump to content

INSER INTO problem with Access and VB... help anyone?


fragglea
 Share

Recommended Posts

Im trying to take a set of variables "AssetNumber" "EquipmentCode" and insert a new record into the [Asset Numbers] table. In a loop to insert a list in a single go.Iv been banging my head on this for a few hours and reduced the SQL statement to the most simple procedure I can.Its looking like this:SQL = "INSERT INTO AssetNumbers([Asset Number]) VALUES ('44'),('43');"the I use the doCmd.runSQL to run the script.I know something is wrong with the script. I just cant see what.The above statement returns the "missing ; ". So what am I missing?This is being used in Access, with VB.

Link to comment
Share on other sites

Alright.Now. Since access apparently cant add tables in a bulk fasion.I can force it to insert one at a time in a loop and remove the "Im about to insert.....".For Loop1 = 1 to 30mySql = "INSERT INTO myTable( ...) " & _"VALUES (" & Loop1 ", ...) " & _CurrentDb.Execute mySql, dbFailOnError Next Loop1This will add one record at a time and surpress the irritating "press 'yes' "message.It takes a little while though...Any thoughts on a speedier way to accomlish this? (give the data is in a "listbox" not another table)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...