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

Concatenation problem with Insert Into syntax

Status
Not open for further replies.

sohunter

Technical User
Dec 3, 2001
106
US
I'm trying to create a text string for one of the target fields in an Insert Into statement, but can't seem to combine a text literal -- in this case, the characters
Invoice: $
with a reference to a field on an open form.

Code:
db.Execute "Insert into Payments (donorID, PaymentMemo) VALUES (" & Forms!Donors.DonorID & ", 'Invoice: $ '" & Forms!Donors.PledgeAmount & ")"

I get:
Run time error 3075 -
Syntax error(missing operator) in query expression "Invoice: $'6'.

Any ideas what's happening? I assume it's with my quotes, but I've tried every variation, without success!
 
Hi sohunter,

I think you're just missing a quote ..

Code:
[blue]db.Execute "Insert into Payments (donorID, PaymentMemo) VALUES (" & Forms!Donors.DonorID & ", 'Invoice: $ '" & Forms!Donors.PledgeAmount & "[highlight][red]'[/red][/highlight])" [/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Hmmm - that didn't work unfortunately. The single quote you suggest doesn't have a pair, shall we say. I'm trying to end up with
Invoice: $6

(or something like that -- the 6 coming from a field on the open form.)

thanks though, sohunter
 
Hi sohunter,

My apologies - I should have taken more care. You're not missing a quote, I think it's just misplaced, so try taking out the one after the $ sign and leaving in the one I wanted to add ..

Code:
[blue]db.Execute "Insert into Payments (donorID, PaymentMemo) VALUES (" & Forms!Donors.DonorID & ", 'Invoice: $" & Forms!Donors.PledgeAmount & "')"[/blue]



Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top