Expression fails when value is "Empty"

G

Guest

The fourth statement in this code returns an error message when the
expression has no value. The error code is 2427 -"You entered an expression
that has no value." When MyValue has a value, in this case a date, then
there is no error. This is part of a function module that I am using to
test the expression for either a value or no value at all.

1. DoCmd.OpenReport "Patient Refill QueryRpt", acViewPreview
2. DoCmd.Maximize
3. DoCmd.RunCommand acCmdZoom100
4. MyValue = Reports![Patient Refill QueryRpt].[ReOrder Date]
5. If IsEmpty (MyValue) = True Then


I have tried many variations of this statement but have not been able to
eliminate the error. Any ideas would be very much appreciated.

John
 
G

Guest

replace 4 and 5 with:

If Len(Reports![Patient Refill QueryRpt].[ReOrder Date] & "") Then
MyValue = Reports![Patient Refill QueryRpt].[ReOrder Date]
Else ...



basically you can check for a value before you set a value. Add an empty
string ("") to what you are checking and it will return a length of 0 rather
than a null error. good luck!

Trace
 
G

Guest

I get the same error message when I tried this code. I also ran
?Len(Reports![Patient Refill QueryRpt].[ReOrder Date] & "")
in the Intermediate window, which gave me the same error message.

John

Tracey said:
replace 4 and 5 with:

If Len(Reports![Patient Refill QueryRpt].[ReOrder Date] & "") Then
MyValue = Reports![Patient Refill QueryRpt].[ReOrder Date]
Else ...



basically you can check for a value before you set a value. Add an empty
string ("") to what you are checking and it will return a length of 0 rather
than a null error. good luck!

Trace

john431 said:
The fourth statement in this code returns an error message when the
expression has no value. The error code is 2427 -"You entered an expression
that has no value." When MyValue has a value, in this case a date, then
there is no error. This is part of a function module that I am using to
test the expression for either a value or no value at all.

1. DoCmd.OpenReport "Patient Refill QueryRpt", acViewPreview
2. DoCmd.Maximize
3. DoCmd.RunCommand acCmdZoom100
4. MyValue = Reports![Patient Refill QueryRpt].[ReOrder Date]
5. If IsEmpty (MyValue) = True Then


I have tried many variations of this statement but have not been able to
eliminate the error. Any ideas would be very much appreciated.

John
 
G

Guest

I found a solution. I replaced lines 4 and 5 with:

If IsDate(Reports![Patient Refill QueryRpt].[ReOrder Date]) = False Then
(statements.......)

Because the expression resulted in a date type, using the IsDate function
appears to be the answer to the error problem .

John

john431 said:
I get the same error message when I tried this code. I also ran
?Len(Reports![Patient Refill QueryRpt].[ReOrder Date] & "")
in the Intermediate window, which gave me the same error message.

John

Tracey said:
replace 4 and 5 with:

If Len(Reports![Patient Refill QueryRpt].[ReOrder Date] & "") Then
MyValue = Reports![Patient Refill QueryRpt].[ReOrder Date]
Else ...



basically you can check for a value before you set a value. Add an empty
string ("") to what you are checking and it will return a length of 0 rather
than a null error. good luck!

Trace

john431 said:
The fourth statement in this code returns an error message when the
expression has no value. The error code is 2427 -"You entered an expression
that has no value." When MyValue has a value, in this case a date, then
there is no error. This is part of a function module that I am using to
test the expression for either a value or no value at all.

1. DoCmd.OpenReport "Patient Refill QueryRpt", acViewPreview
2. DoCmd.Maximize
3. DoCmd.RunCommand acCmdZoom100
4. MyValue = Reports![Patient Refill QueryRpt].[ReOrder Date]
5. If IsEmpty (MyValue) = True Then


I have tried many variations of this statement but have not been able to
eliminate the error. Any ideas would be very much appreciated.

John
 
G

Guest

I have about the same within my database.
I've managed to work it around by
If IsNull(Me.EmailSubject.Value) = True Then
msgbox "no subject" .........

Harry
 

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