trying to do a if something blank do this else do this. same code works on a different form

M

mgworek

If ge > "" Then
sql statement
else
sql statement
end if


ge is a simple text box. my sql statements are fine.

I have the same code running on a different form that also has a
simple text box, it runs just fine.

I can post me entire code if needed.
 
J

John W. Vinson

If ge > "" Then
sql statement
else
sql statement
end if


ge is a simple text box. my sql statements are fine.

I have the same code running on a different form that also has a
simple text box, it runs just fine.

I can post me entire code if needed.

If you're including SQL statements in the middle of VBA code, it *won't work*.
VBA is one language, SQL is another!

Please post the actual IF block and indicate what you expect the code to do.

John W. Vinson [MVP]
 
M

mgworek

I was calling the sql statements through vba.

If Me.ge > "" Then
strSQL2 = "INSERT INTO [RITE INFORMATION] ([STORE NUMBER], CUSTOMER,
ADDRESS, CITY, STATE, [ZIP CODE], [CO LINE 1], [NABP NUMBER], [FAX
PHONE NUMBER], [VRU INSTALLED], [IVR SERIAL PRINTER], [DR FAX], [RX
PICKUP], [REDUNDANT IVR], [INTERNET REFILL], [REFILL ASSISTANT],
[QUICK LINK], [SIG CAP INSTALLED], [CUSTOMER CATEGORY]) " _
& "VALUES ('" & sn & "', '" & Replace(Me.[cu], "'", "''") & "', '" &
Replace(Me.[ad], "'", "''") & "', '" & Replace(Me.[ci], "'", "''") &
"', '" & st & "', '" & zip & "','" & co & "', '" & nab & "','" & fa &
"' , '" & iv & "', '" & pri & "', '" & dr & "', '" & rx & "', '" &
redundant & "', '" & internet & "', '" & refill & "', '" & quick & "',
'" & sig & "', '" & Replace(Me.[cat], "'", "''") & "')"
CurrentDb.Execute (strSQL2)
strSQL3 = "INSERT INTO [Base_Unit] ([STORE NUMBER]) VALUES ( '" & sn &
"')"
CurrentDb.Execute (strSQL3)
Else
strSQL = "INSERT INTO [INFORMATION] ([STORE NUMBER], CUSTOMER,
ADDRESS, CITY, STATE, [ZIP CODE], [CO LINE 1], [NABP NUMBER], [FAX
PHONE NUMBER], [VRU INSTALLED], [IVR SERIAL PRINTER], [DR FAX], [RX
PICKUP], [REDUNDANT IVR], [INTERNET REFILL], [REFILL ASSISTANT],
[QUICK LINK], [SIG CAP INSTALLED], [CUSTOMER CATEGORY], [GENERAL
COMMENTS]) " _
& "VALUES ('" & sn & "', '" & Replace(Me.[cu], "'", "''") & "', '" &
Replace(Me.[ad], "'", "''") & "', '" & Replace(Me.[ci], "'", "''") &
"', '" & st & "', '" & zip & "','" & co & "', '" & nab & "','" & fa &
"' , '" & iv & "', '" & pri & "', '" & dr & "', '" & rx & "', '" &
redundant & "', '" & internet & "', '" & refill & "', '" & quick & "',
'" & sig & "', '" & Replace(Me.[cat], "'", "''") & "', '" & Replace(Me.
[ge], "'", "''") & "')"
CurrentDb.Execute (strSQL)
strSQL1 = "INSERT INTO [Base_Unit] ([STORE NUMBER]) VALUES ( '" & sn &
"')"
CurrentDb.Execute (strSQL1)
End If

the sql/vba code is the same between the two cept i am inserting one
more thing in one of them.
they work alone without the if statements.
 
J

John W. Vinson

I was calling the sql statements through vba.

Whoo... with all those nested quotes I don't know if I can parse these at all!
Try stepping through the code in debug mode and display strSQL1 and strSQL in
the Immediate window; if there isn't some blatantly obvious error post the
actual constructed strings here.

John W. Vinson [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