By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

INSERT INTO Query

P: n/a
I have a SQL statement that is not working.

It reads as follows:

sql = "INSERT INTO tblPaymentInformation ([AuctionDate], [BidderNumber],
[PaymentType], [PaymentNumber], [Amount]) VALUES ('aucdte', 'bidnum',
'paytyp', 'paynum', payamt)"

The variables for the VALUES section are assigned before this sql
statement. The problem occures with the payamt varable. It is a currency
field. When I try to run the SQL statement, it pops an input box asking
payamt.

If I add the ' around the varaable Access gives me a conversion error.
How do I get this to work with a currency varable?

Michael

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try "...................VALUES ('" & aucdte & "', '" & bidnum & "', '" &
paytyp & "', '" & paynum & "'," & payamt & ")"

Clive

"Nothing" <me@you.com> wrote in message
news:3f*********************@news.frii.net...
I have a SQL statement that is not working.

It reads as follows:

sql = "INSERT INTO tblPaymentInformation ([AuctionDate], [BidderNumber],
[PaymentType], [PaymentNumber], [Amount]) VALUES ('aucdte', 'bidnum',
'paytyp', 'paynum', payamt)"

The variables for the VALUES section are assigned before this sql
statement. The problem occures with the payamt varable. It is a currency
field. When I try to run the SQL statement, it pops an input box asking
payamt.

If I add the ' around the varaable Access gives me a conversion error.
How do I get this to work with a currency varable?

Michael

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2

P: n/a
If you look at your table, you'll find that you've acutally inserted the
variable names (aucdte, bidnum, etc) in your table ... instead of the VALUES
of the variables. To do that, you need to do this:

sql = "INSERT INTO tblPaymentInformation ([AuctionDate], [BidderNumber],
[PaymentType], [PaymentNumber], [Amount]) VALUES (' " & aucdte & ' ",' " &
bidnum & " ',' " & paytyp & " ',' " & paynum & " '," & payamt & ")"

Note that I have included spaces between the single quotes ( ' ) and the
double quotes ( " ) for readability. In general you do NOT need these spaces
would be advised to remove them before running your insert statement. Note
also that this is "air code" and as such may have some typos ... in general,
you get the idea though.

"Nothing" <me@you.com> wrote in message
news:3f*********************@news.frii.net...
I have a SQL statement that is not working.

It reads as follows:

sql = "INSERT INTO tblPaymentInformation ([AuctionDate], [BidderNumber],
[PaymentType], [PaymentNumber], [Amount]) VALUES ('aucdte', 'bidnum',
'paytyp', 'paynum', payamt)"

The variables for the VALUES section are assigned before this sql
statement. The problem occures with the payamt varable. It is a currency
field. When I try to run the SQL statement, it pops an input box asking
payamt.

If I add the ' around the varaable Access gives me a conversion error.
How do I get this to work with a currency varable?

Michael

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.