Module help needed

arage

Registered User.
Local time
Today, 14:26
Joined
Dec 30, 2000
Messages
537
Hi,
I have a standard module that is meant to verify if certain fields are blank but when my class module calls the standard module, the IF statements in the standard module aren’t running even though the condition is satisfied. I even checked the debugger to be sure the field is Null. Please advise as I’ ve done only minimal standard module coding before this time.
CLASS MODULE CODE:

If Me.TotalPays <> 0 Then
Call verifyCPRMain(ctrlname, lblcaption)
End If

STANDARD MODULE CODE:

Dim ctrlname As String, lblcaption As String
Dim arg1 As String, arg2 As String

Option Compare Database
Option Explicit

Sub verifyCPRMain(arg1, arg2)

If Forms![data entry]![cpr.dateentered] = Null Then
arg1 = [Forms]![data entry]![CPR_dateentred]
arg2 = [Forms]![data entry]!Label37
Call isBlank(ctrlname, lblcaption)
End If

If [Forms]![data entry]!EventResults = Null Then
arg1 = [Forms]![data entry]!EventResults
arg2 = [Forms]![data entry]!Label38
Call isBlank(ctrlname, lblcaption)
End If

End Sub
 
Instead of "= Null" try using "is null". That should do the trick.

~ Joe
 
I've had occasionally had problems with fields, that I believe to be null, not returning true using 'is null'. Particularly if they formally had a value that has been deleted. If this should prove to be the case for you, here's an example of what I do.

IF IsNull([field])=True or [Field]="" Then

I hope this helps.

~Abby N
 
Thanks Abby your code worked.

but it seems now that my code is 'jumping the gun' & giving an err msg the moment a new record (a blank) is brought up for the
user to enter into. Does a new(blank) record have an BeforeUpdate event? because my class module is calling to find out if certain fields are blank on the beforeUpdate event, but i don't need to check it if the record is brand new.
 
The BeforeUpdate event doesn’t take place by entering a new record. Though exiting the old record could trigger it. Additionally, it could be that something in you code is triggering the event. Without seeing your form, it's difficult to know how best to handle that. But, if you can find a condition that's true when you want the module to run and false when you don’t, then you can use that as criteria in an ‘If…Then’ statement and place the call for you module in it.

~Abby
 

Users who are viewing this thread

Back
Top Bottom