If statement does not work!!!

u0107

Board Regular
Joined
Dec 18, 2002
Messages
154
Hello,

One of the most basic of Logical constructs using the IF statement in Access does not work every time.

I have a form in which there are many elements - nearly 60 or so. Of them 10 are in the nature of must be filled elements.

In my logic, for each of these fields, I have a "Lost Focus" Event. Each of the Lost Focus events call a common Public Sub in which the value of each of the fields are checked.

In the common routine, I have a "Found_Flag" dimensioned as Boolean and set to value True at the start of the call.

Next for each field, I check what the value is - if Null or Zero, then the flag is set to false.

At the end of the call, I check the value - if false, then at least one of the fields has been missed.

I find that some of the If statements do not come true which is proved by examination of values in the Immediate Window.

THis is a sample of If statements - I must be missing the wood for the forest here.. can anyone explain why this is happening.?

If (Me.Controls.Item(18).Value = Null) Then
Found_Flag = False
End If


This is from the Immediate window:
?Me.Controls.Item(18).value
Null

But Found_Flag was NOT turned to False here..

Hope someone can explain!!!

Thanks in advance

Uttam
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
try
If IsNull(Me.Controls.Item(18).Value) Then
Found_Flag = False
End If

Peter
 
Upvote 0

Forum statistics

Threads
1,221,573
Messages
6,160,593
Members
451,657
Latest member
Ang24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top