By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 1,508 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

Help: Inserting values from a TextBox into a database

P: 1
Good day
I am having some struggles on how to input data into a database when a user has filled out numerous textbox fields.

I simplified my example down to a single database with two fields ID (the primary key) and name (the name of the car).

The name of the TextBox is textbox_name

I do not know what syntax to use to get the values of the textbox into the SQL query.


INSERT INTO cars ( name )
VALUES ([textbox_name].[text]);


How do I go about doing the above from VBA? I get an error when I declare the Dim Car_db = DAO.Database
Dim Car_recordset = DAO.RecordSet


Your advice would be much appreicated
Mar 13 '07 #1
Share this Question
Share on Google+
4 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Good day
I am having some struggles on how to input data into a database when a user has filled out numerous textbox fields.

I simplified my example down to a single database with two fields ID (the primary key) and name (the name of the car).

The name of the TextBox is textbox_name

I do not know what syntax to use to get the values of the textbox into the SQL query.


INSERT INTO cars ( name )
VALUES ([textbox_name].[text]);


How do I go about doing the above from VBA? I get an error when I declare the Dim Car_db = DAO.Database
Dim Car_recordset = DAO.RecordSet


Your advice would be much appreicated
Look under Tools - References and check that the Microsoft DAO library is ticked. Version 3.6 or above ideally.

Mary
Mar 13 '07 #2

NeoPa
Expert Mod 15k+
P: 31,276
Try using :
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO cars ( name )
  2. VALUES (Forms!YourFormName.[textbox_name]);
Mar 15 '07 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
Just realised the syntax you used. There is no '=' sign in these statements.

Expand|Select|Wrap|Line Numbers
  1. Dim Car_db DAO.Database
  2. Dim Car_recordset DAO.RecordSet
Mary
Mar 15 '07 #4

NeoPa
Expert Mod 15k+
P: 31,276
Just realised the syntax you used. There is no '=' sign in these statements.

Expand|Select|Wrap|Line Numbers
  1. Dim Car_db DAO.Database
  2. Dim Car_recordset DAO.RecordSet
Mary
Not too surprising in the circumstances as the OP posted the code in standard text and avoided the use of the [code] tags :(
Mar 16 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.