Can't exit Sub on condition

Precisio

New member
Local time
Yesterday, 17:42
Joined
Jul 24, 2009
Messages
3
Help, I'm dying here, completely stumped.

I have a form with a subform. When the form/subform open for the first time, it causes an error in my (sub)Form_current procedure because the fields are not populated yet (typically and action on the form brings up the record in the subform). I know from reading that subform loads/goes current first, which is causeing this error, but I figured that an easy way to handle it would be just to exit the Form_current procedure if the problem value is not populated (i.e., is NULL).

So, I created the code shown in the attached picture. In the picture, I've stepped a couple times through the Sub and you can see in the immediate window that the field I'm checking for is indeed showing NULL. But then my condition just runs past, it doesn't EXIT SUB :confused::mad:.

I'm missing something, any help is appreciated!
 

Attachments

  • vba debug.jpg
    vba debug.jpg
    88.5 KB · Views: 118
You can't check for nulls with = Null you have to use

If IsNull(Me.ProjectID) Then
 
Nothing is ever equal to Null. Your test should be:

If IsNull(Whatever) Then
 
OMG you guys Rock!!!!! :):)

That worked like a charm. I knew I was missing something simple like that! I'm still learning all this stuff. I guess messing up is the best way to learn, I'll never forget this one!

Thanks again!
 

Users who are viewing this thread

Back
Top Bottom