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!

Need help on the format of this INSERT INTO code

Status
Not open for further replies.

dvlarsen619

Programmer
Feb 3, 2008
5
US
I just can't quite get the quotes right on this. Can somebody please help me? I am sure it is the "Double then Single Quotations" where the problem is. Thank you.

strSQL1 = "INSERT INTO tblRateZoneCharges(RateZoneID, ChargeID)" _
& " VALUES (" & Me!RateZoneID & "," _
& "'AT'" & " ')"
strSQL2 = "INSERT INTO tbl_RateZoneCharges(RateZoneID, ChargeID)" _
& " VALUES (" & Me!RateZoneID & "," _
& "'BA'" & "')"
strSQL3 = "INSERT INTO tbl_RateZoneCharges(RateZoneID, ChargeID)" _
& " VALUES (" & Me!RateZoneID & "," _
& "'DX'" & "')"
 
Try this
Code:
strSQL1 = "INSERT INTO tblRateZoneCharges(RateZoneID, ChargeID)" _
    & " VALUES ('" & Me!RateZoneID & "'," _
    & "'AT'" & " ')"
strSQL2 = "INSERT INTO tbl_RateZoneCharges(RateZoneID, ChargeID)" _
    & " VALUES ('" & Me!RateZoneID & "'," _
    & "'BA'" & "')"
strSQL3 = "INSERT INTO tbl_RateZoneCharges(RateZoneID, ChargeID)" _
    & " VALUES ('" & Me!RateZoneID & "'," _
    & "'DX'" & "')"

ck1999
 
Not tested but try:
Code:
strSQL1 = "INSERT INTO tblRateZoneCharges(RateZoneID, ChargeID)" _
    & " VALUES (" & Me!RateZoneID & ",'AT')"
    
strSQL2 = "INSERT INTO tbl_RateZoneCharges(RateZoneID, ChargeID)" _
    & " VALUES (" & Me!RateZoneID & ",'BA')"
    
strSQL3 = "INSERT INTO tbl_RateZoneCharges(RateZoneID, ChargeID)" _
    & " VALUES (" & Me!RateZoneID & ",'DX')"

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
I should have asked what format Me!RateZoneID is.

if this is a string then single quotes around the field as posted by ck1999 e.g. VALUES ('" & Me!RateZoneID & "','DX')"

else as per my last. I think the final single quote in your original may have been causing issues.

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
how are ya dvlarsen619 . . .

. . . and this:
Code:
[blue]   Dim basSQL As String, SQL1 As String, SQL2 As String, SQL3 As String

   basSQL = "INSERT INTO tblRateZoneCharges(RateZoneID, ChargeID) " & _
                  " VALUES (" & Me!RateZoneID & ", "
   SQL1 = basSQL & "'AT');"
   SQL2 = basSQL & "'BA');"
   SQL3 = basSQL & "'DX');"[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top