View Full Version : Please someone help a newbie !


PhilipEwen
10-09-2001, 05:28 PM
Hi,
sorry if this is really basic to you all, but i am stuck and have searched and searched but to no avail. ( it would probably help if i knew exactly what to search for ! )
What i am doing is adding data to a table when a button is pushed ( code bound to button )
i have 2 unbound text boxes - when i hit the button i want the data from those boxes to be put in table.

I can do it for 1 text box
ss = "INSERT INTO [resorts](resortname) VALUES (txt_resort_name)"
DoCmd.RunSQL ss

But how do i do it for both ? If i run this once for the resortname, then run the statement again with the txt_transfer_cost data, it just adds a new entry to the table, so that the name and cost are not on the same entry.

There must be a way of joining the statements together so that it will insert the data to both fields...

ss = "INSERT INTO [resorts](resortname) VALUES (txt_resort_name)"
ss = ss & "INSERT INTO [resorts](transfercost) VALUES (txt_trans_cost)"
DoCmd.RunSQL ss

This is what i did but keep coming up with errors of missing semicolons etc etc

PLEASE PLEASE HELP !

Thanks

Phil.

PhilipEwen
10-09-2001, 05:46 PM
Forget it - found the solution...it was a syntax problem

ss = "INSERT INTO resorts " & "(resortname,transfercost) VALUES " & "(txt_resort_name, txt_trans_cost);"

aqif
10-09-2001, 05:49 PM
Hi http://www.access-programmers.co.uk/ubb/smile.gif

I searched help and u can easily mention >1 fields in ur Insert query, just replace the FirstName etc with ur control names and hope it'll work OK. I m pasting the Access help file portion also

INSERT INTO Employees (FirstName,LastName, Title) VALUES ('Harry', 'Washington', 'Trainee');

The above example creates a new record in the Employees table:

Cheers!
Aqif

PhilipEwen
10-09-2001, 05:51 PM
Thanks for your efforts - i had just looked at the same thing myself !!
Much appreciated though -itt's so annoying that it's so simple, yet you don't know where to start looking !!

many thanks again !

Phil.