INSERT Multiple strings in Table

D

Duck

I want to insert into a file which has only two fields ([UserName],
[Passwd]), the users UserName for each field. This is used as the
default initial password for users when they are added to the
database. I have a command button on a form, which also contains a
text field ([UserName]) that runs the command:

CurrentDb.Execute "INSERT INTO tblPasswd(UserName, Passwd)
VALUES('"&Me.UserName&"', '"&Me.UserName&"');"

However no matter how rearrange the command I either get a syntax
error or an "expected end of statement" error with the double quote,
single quote, comma, single quote, double quote, between the two value
variables highlighted.
 
T

Tom van Stiphout

On Mon, 1 Sep 2008 08:58:52 -0700 (PDT), Duck

You need a space before and after the & string concatenation operator.
a&b ==> illegal
a & b ==> OK

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top