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

Update query to add new row

Status
Not open for further replies.

JohnMcCririck

Technical User
Jan 10, 2005
4
GB
I have heard that an update query can be used to add a new row to a table... for example once a user fills out a form the update query would run and save the fields to a new row in the designated table.

Is this all crazy talk?
 
I think it is. INSERT queries add new rows. UPDATE queries change existing rows.
 
Thanks for the quick reply!

I've never heard of an INSERT query, would it be suitable for adding a new row to a table from data inputted into text boxes on a form?
 
Sure
Code:
SQL = _
"INSERT INTO tablename (f1, f2) " & _

"VALUES ('" & txtbox1.Text & "', '" & txtbox2.Text & "' )"
Inserts a new record into table "tablename" and assigns the values from two text boxes to fields "f1" and "f2". The syntax changes slightly for different data types.
 
Running into problems now...

My table has 3 fields from user inputted data (text boxes on a form), an autonumber field, a field showing date of entry, and 2 more fields which are calculated.

How would I go about inserting them all? Should I try inserting the results of another query that runs previous to the INSERT query?

(I know you're not supposed to store calculated fields but I want to in this case)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top