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

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.

0
mgworek
6/15/2007 9:04:52 PM
access.formscoding 7493 articles. 0 followers. Follow

4 Replies
603 Views

Similar Articles

[PageSpeed] 30

What is the question?
-- 
KARL DEWEY
Build a little - Test a little


"mgworek" wrote:

> 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.
> 
> 
0
Utf
6/15/2007 9:20:01 PM
On Fri, 15 Jun 2007 14:04:52 -0700, mgworek <mgworek@voicetechinc.com> wrote:

>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]
0
John
6/15/2007 9:48:43 PM
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.

On Jun 15, 5:48 pm, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> On Fri, 15 Jun 2007 14:04:52 -0700, mgworek <mgwo...@voicetechinc.com> wrote:
> >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]


0
mgworek
6/18/2007 1:00:34 PM
On Mon, 18 Jun 2007 06:00:34 -0700, mgworek <mgworek@voicetechinc.com> wrote:

>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]
0
John
6/18/2007 10:36:19 PM
Reply:

Similar Artilces:

open two different Access reports
Hi, I was wondering if i can get some help here. I have two different reports that i want to open when a user clicks a button to view the reports for printing. Is there any way of popping them up at the same time in VBA? Thank you in advance Associates wrote: >Hi, > >I was wondering if i can get some help here. I have two different reports >that i want to open when a user clicks a button to view the reports for >printing. Is there any way of popping them up at the same time in VBA? > >Thank you in advance Yes. Call the DoCmd.OpenReport command twic...

Steps to Share Outlook on 2 different drives
This is a problem created by a dual boot of XPPSP2 on one drive C:\ and Vista on another drive E:\ that I use to format for new builds of Vista on the same box. I want to take my Outlook 2003 in box and folders on two different drives on one box and combine them so that all the emails go to one account and all the folders can be shared or used on each drive. I want to do the same with Outlook Express as well, and since this is an *Outlook newsgroup, I'll just take what I learn here and apply it to the ..dbx folder(s) in it. The idea is to receive email on both drives in one in one...

code examples for BITS
Hi, I am looking for sample codes for programming background intelligent transfer service..I was able to see sample code in .NET, but I'm specifically looking for VC++ 6.0 (command-line application).Please help me.. Thanks, NKH ...

Access 2007 and Vista code problem
I am developing a database on a XP SP2 machine. On a form I have created some buttons with event procedures that run 2 queries and open a form. I sent the db to someone running Access 2007 on a Vista machine and nothing happens when she clicks the buttons and there are no messages. I know nothing about Vista so thanks in advance for any help. Tim Might be a reference problem, have them open the open a code window and click tools references. See what says missing and tell them what should be there, Add it and it should work. Duff "Tim Reid" <TimReid@discussions.micr...

Word2007. Checkbox. No Form
Hello! We have a document (not a form) that we would like to use checkboxes in. This document has a couple of sections where it would be useful if the user could check if something is applicable. We can't protect the whole document. Thank you for your help! Stacey I actually used this feature in a form this morning. Although you don't say what version of Word you are using, you can access the Control Toolbox toolbar in Word 2003, or in Word 2007, it is on Developer tab. To show the developer tab, click the Microsoft Office Button and then click Word Options. S...

VBA to creating autotext entries or quickparts in different catego
I have a VBA application that basically allows people to easily create autotext entiries, move them between machines and use them making comments on assignments. Currently it operates in EXACTLY the same way in Word 2003 and 2007 (using userforms) and I want to keep that as long as possible. You can see the application at http://emarking-assistant.baker-evans.com and either the screen image or the video demos will give you an idea of what I am doing Currently I store all the comments in a long list of autotext entries that is displayed in a field with the value of the entr...

Change the Exchange Virtual Directory to different website
I would like to remove the exchange virtual directory default website and move it another website which is currently redirecting to the website I want to delete. Meaning rather than logon to OWA as http://www.wheresmylunch.com/exchange (current default website) I want to move to http://www.getyourownsandwich,com/exchange. I am using Exchange 2000 server. Rube You would change the host header on the current website. -- Hope that helps, Dan Townsend This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send email to this address, post a reply t...

I would like to know how to set up a 'fill in the blanks' form?
I would like to set up a templet of sorts to fill in the blanks for certificates. ...

Ctrl+D not working on outlook messages
Any idea why? alltimefav wrote: > Any idea why? And what are you expecting to happen? "alltimefav" wrote in message news:a95c52df-a387-4a8f-bf9d-269ff485451f@i29g2000prf.googlegroups.com... > Any idea why? So instead of hitting Ctrl+D to delete an item, what happens when the item is selected and you hit the Del key, or the "X" toolbar button, or right-click on the item and select Delete? Did you really expect a detailed response for such a vague question? You didn't even bother to say what "not working" means, like the item does not get delete...

how to make macro work even a sheet is hidden.
hello there I have macro assigned to a button in Sheet 1 which goes to sheet 2. Press a button to Refresh and then PRINT preview It does work in normal state. I do not want the user to see the Sheet 2. I hid sheets from Format-sheet-hide. but the macro is not working when sheet 2 is hidden. how to overcome this error "can't execute code in break mode" the macro code is Sub Print_Preview() Sheets("PaySlips2009-10").Select Application.Run "'Latest 2009Payslip.xls'!Sheet2.HURows" ActiveWindow.SelectedSheets.PrintPreview ...

Some Excel formatting functions taking a long time to work #2
Excel 2000 SP3 When I use some formatting functions for the first time in a session, such as bold, increasing font size etc, it takes up to 30 seconds to work. Meantime Excel is locked up until it completes that formatting call. I suspect faulty DLL? Has anyone experienced this? How to fix (other than a complete re- install) ? Any advice appreciated. Piri On Nov 5, 8:39=A0am, Piri <wiremu.pare...@hotmail.com> wrote: > Excel 2000 SP3 > When I use some formatting functions for the first time in a > session, such as bold, increasing font size etc, it takes =A0up to 30 > secon...

Merge code issues with Publisher 2003
It seems whenever the data source is altered, the merge code fields have to be reinserted in the Publisher document. Is this normal? The data source starts in Excel and is then saved as a .txt file to retain number formatting on final merge. ...

Mailboxsize is different
hi! i've got a crazy problem. when you look at the mailboxes in the exchange system manager, then you see, e.g. user xy with 220 mb mailboxsize. but when you look at the outlook, then the mailbox size is only 150 mb. but there are no filters or something else activated. and the problem is on the local outlook and on the terminalserver outlook. i hope someone has a solution about my problem. thanks. stefan ...

why does my spell check not work?
My spell check has never worked. What can I do to set it up? In what program / version "karen" <karen@discussions.microsoft.com> wrote in message news:DA8883BD-0958-4AB0-93FF-F43E4FB9D176@microsoft.com... > My spell check has never worked. What can I do to set it up? ...

SUTA state message on Pay Code Integration
I'm having trouble importing pay codes that are based on another code, such as Sick and Vacation. These records get rejected with the error message "pay code 'V' requires a SUTA state". I have a SUTA state in the Emp Maint window and the HOURLY pay code already exists and contains a SUTA state. I tried mapping the SUTA State code in my file and even tried using a Constant value in Destination mapping but these codes will not import. I can go into the Pay Code Maintenance window and add these codes manually with no problem. What am I missing? ...

Date function quit working
Hi, I have an Access 2002 application that I have been running on Windows XP SP2 without issue. I just installed the application (running in Access Runtime) on a Windows Vista Home Premium machine. Now, anywhere I used the =Date() function, it fails and just shows #Name? I also have a subform on one of my forms that has now gone blank. It also uses the date function. I had this problem when I converted to Windows XP several years ago and updating the OWC10.dll to version 6619 fixed both issues. However, everything I have read says that reference file makes no difference to the Access...

Value is BLANK
In a form i'm working on i've asked this question before and i'm unable to locate the replies, but in one cell I have a date to be enter and in the other cell it takes that date and add 5 days to the date to give me a due date. But if no date is enter then I want to to remain blank insted giving me a date. Say that the date is to be entered into A1, then enter this formula into the "other" cell: =IF(A1,A1+5,"") -- HTH, RD ============================================== Please keep all correspondence within the Group, so all may benefit! ==================...

MS Access 2007 code not running
I have created a brand new database in Access 2007 and linked some VB code to run on Form_Load. This code worked perfect with no problems the day I created it. Now today I opened the same form and it is not running the Form_Load code anymore (and yes it is still there, I did not delete it). I got frustrated so I copied and pasted the code to Form_Current and several On_Change events and set breakpoints at the beginning of all the events just to see if it was the Form_Load that was not triggering, but NO events are triggering my VB code. Any ideas? See this page: http://accessjunkie.com/fa...

Word 2003: Will it work on Windows 7 Pro
The ads say there is virtual XP on Windows 7 that can run programs like Word 2003. In your experience is this true? On any Windows 7 machine? Does 64 versus 32 bit processor matter for either Word/Office 2003 or Office 2007? thanks. You don't need Virtual XP to run Office 2003 on Windows 7. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "removing all headers and footers" <removingallheadersandfooters@discussions.microsoft.com> wrote in message news:95298031-44F6-4E74-A608-C76987DFAB46@microsoft....

Adding blank "separator" Rows in a Pivot Table
Does anyone know how to insert blank rows into a pivot table (say, between groupings, etc.)? There has to be a way, since some of the various table formats that come with Excel include blank rows. Double-click the field button that you want to format Click Layout Add a checkmark to Insert blank line after each item Click OK, twice Bucko wrote: > Does anyone know how to insert blank rows into a pivot table (say, > between groupings, etc.)? There has to be a way, since some of the > various table formats that come with Excel include blank rows. -- Debra Dalgleish Contextures http...

Picture control on a form
What is the best way to fill a form with a picture control so that when the client window is resized the picture control will fill the form? -- Just Al Take a look at this and see if this is what you want: http://www.codeproject.com/dialog/bmpdlg01.asp Tom "Al" <Al@discussions.microsoft.com> wrote in message news:5BEA0FA2-3F95-4090-B908-A75DBF1D19DE@microsoft.com... > What is the best way to fill a form with a picture control so that when > the > client window is resized the picture control will fill the form? > -- > Just Al Thank You! -- Just Al &...

Null value in form not trapped by beforeupdate event
I have a form in Access 2003 linked to a SQL Server 2005 table. When I clear the value in a textbox (bound field is varchar and is required), I want the before update event to run to tell the user the value cannot be null. When I press the tab button to move to the next field after clearing the texbox, the before update event is not triggering and instead I'm getting the following error: You tried to assign the Null value to a variable that is not a Variant data type. (Error 3162) How can I prevent nulls before and this error from triggering? Thanks! ...

Selecting the Right Text Alignment for a edit box doesn't work
When I select right text alignment in the edit control properties, the text is still left aligned when I run the program. What am I doing wrong Thanks Dan Dan, "Dan" <anonymous@discussions.microsoft.com> a �crit dans le message de news:DECFE605-A130-416B-9924-60BA0C79D684@microsoft.com... > When I select right text alignment in the edit control properties, the text is still left aligned when I run the program. What am I doing wrong? > I've no idea :-))) You can open your RC-file as text, and make sure it has the ES_RIGHT style set, thus: EDITTEXT IDC...

Copy and close code
Hi, I have a worksheet which uses an indirect formula to search through a series of files/sheets based on an address to return a value from cell AE20. Once the data has been copied for all the previous days I would like a copy/paste values to occur to replace any of the values returned by the formula. In AU10:AU381 there is a 1 or 0 for each row. 1 meaning that a copy/pastevalues can be performed (decided by if the date is < today), and zero if i need to keep the formulas. Is it possible to have a copy/paste values code for only sheets 2-4 which works when the file is...

copy values generated by conditional formula in one sheet to the other work sheet as values
Hi Everybody, I have data generated by conditional formulae in work sheet1 in columns A to J. If the condition is satisfied the cell will display a realnumber, if the condition doesn't satisfied the cell will display the text"FALSE". Now I wanted to copy the cells which have the real numbers in sheet1 to sheet2 as values(as we do with paste special and paste the values) Do we have any formula or other method to copy the cells in sheet1 to sheet2. can anybody helpme out in this issue. Thanks and Regards Ramana Select your range to copy edit|goto|special|c...