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

new query?

Status
Not open for further replies.

Olavxxx

Programmer
Sep 21, 2004
1,134
NO
Hi,

I used this VBA, for inserting in another db:
Code:
CurrentProject.Connection.Execute "INSERT INTO kunde " & _
"SELECT navn AS kundenavn, id AS ekspd_id FROM tbl_navn " & _
"WHERE id = " & tmpId & " AND " & _
"skal_digitaliseres=True And sendt_til_dig=False;"

it worked fine, but I now, however, want to rebuild it.
Instead of inserting the value from the DB, I want to insert some global arrays I defined in the project.

I tried this code:
Code:
CurrentProject.Connection.Execute ("INSERT INTO kunde " & _
                    "(id, kundenavn, ekspd_id) VALUES ('', " & tmpNavn & "," & tmpId & ");")

I need to do this, since db1 has one field for name, while db2 has two fields for name.

I've already made a VBA function to divide the name into fnam and lnam (Firstname and Lastname), so the rest should be simple, if I can get my query working.

I will also have to insert some other data from db1.table1 to db2.table2.

eg. db1.table1.field1 => db2.table1.field1 and .field2
db1.table1.field2 => db2.table2.field1

Olav Alexander Mjelde
Admin & Webmaster
 
oh, I forgot the error message.
it says one of the fields is missing data.

id is autonumber.
I tried leaving the id out, but it still says the same.

Olav Alexander Mjelde
Admin & Webmaster
 
sorry, I forgot the '' capsuling the values.

Code:
CurrentProject.Connection.Execute ("INSERT INTO kunde " & _
                    "(kundenavn, ekspd_id) VALUES ('" & tmpNavn & "','" & tmpId & "');")

too little coffee..

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top