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

sql question 1

Status
Not open for further replies.

djam

Technical User
Nov 15, 2002
223
CA
how would I use a entry in a field as part of the sql statment??

db.Execute "insert into tst_table (NAME) values (fieldname)"
"so many events, so little time"
 
[worm]
Code:
"INSERT INTO Employees (FirstName, LastName) VALUES ('" & [FName] & "', '" & [LName] & "');"
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
to vbslammer
please can you explain this to me
is value a keyword help did not bring up anything
what is djam trying to do
 
"values" is a keyword in sql, it just means put these values into the fields that I selected

if you need more info, just look at sql references "so many events, so little time"
 
is this the same like
"INSERT INTO Employees (FirstName, LastName) SELECT '[fname]' AS Expr1, '[lname]' AS Expr2;"
 
Since the values to insert are taken from a textbox on a form (data entry) they can't be determined at design time, that's why you need to structure the SQL statement to concatenate the unknown values into it at runtime.

In this example, if [FName] is bound to a source other than the SQL statement's source (or unbound), it can't be hardcoded into the SQL statement - that's why we just get its value at runtime and place it into the statement:

Code:
"INSERT INTO Employees (FirstName, LastName) VALUES ('" & [FName] & "', '" & [LName] & "');"
becomes something like:
Code:
"INSERT INTO Employees (FirstName, LastName) VALUES ('William', 'Gates');"
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top