My Assistant
![]() ![]() |
|
|
Oct 10 2004, 10:10 PM
Post
#1
|
|
|
New Member Posts: 9 |
I have been looking over the net and i cant seem to find anyone who has entered data with just an insert statement. Can anyone help me with some code for it, just 2 textfields which insert thier data into 2 different tables when a button is clicked. Can anybody please help?
|
|
|
|
Oct 10 2004, 10:47 PM
Post
#2
|
|
|
UtterAccess Guru Posts: 703 |
Well I will tell you how to do it with one text field, and for two you would just do it twice. Take for example a table:
CODE TblEmployees ID First Last 1 Frank Oz 2 June Jones 3 Bob Smith You form has two unbound text boxes named "FirstNameBox" and "LastNameBox", and a button named "AddNameButton" In the AddNameButton's OnClick event, add the following code: CODE DIM strSQL as String strSQL = "INSERT INTO TblEmployees (Name) VALUES ('" & me.FirstNameBox & ", '" & me.LastNameBox & "')" CurrentDB.Execute strSQL If you entered 'Jim' into FirstNameBox, 'Jenkins' into LastNameBox, and clicked the button, the result would be: CODE ID First Last
1 Frank Oz 2 June Jones 3 Bob Smith 4 Jim Jenkins |
|
|
|
Oct 10 2004, 10:51 PM
Post
#3
|
|
|
UA Forum Administrator Posts: 38,073 From: Birmingham, Alabama USA |
If this is for an existing record ... use an Update Query ...
If this is for a new record ... use an Append Query ... RDH |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 21st May 2013 - 06:03 AM |