On Close event error

P

PowerPoint Jedi

Hi,
I am having a problem with some code I wrote for a form. This seems to
be a 2 part problem.

The first part is that when the form it runs a query to populate the fields
on the form. If there are no records meeting the criteria the form doesn't
populate and you just see the grey background. This in itself is not a
problem as there are situations when there are going to be no records meeting
the criteria

The second part is where I am having issues. I am wrote code to correspond
to the onclose event. This code checks a certain field to determine if it
should perform a function. When the above query returns no values and I
close the form I get a runtime error stating that the field it is looking for
has no value.

I understand why this is happening but have no idea how to get around it.
It looks like I need a way in the onclose event to check first if there were
values returned in the initial query prior to running the function. If this
is the case I need to be able to just close the form skipping the function
and not getting the runtime error.

Any ideas? If you are confused please post questions and I will do my best
to clear up the confusion

Thanks you

I am running access 2003
 
P

Paul

Try the following:

If IsNull(Me.Textbox1) = False Then
...perform the function
End If

Regards,

Paul
 
P

PowerPoint Jedi

Paul
Thanks, I tried what you suggested but i still get the same runtime error

Runtime error 2427
you have entered an expression with no value

The problem seem to be this
1. The form runs the query when it opens
2. The query returns no values resulting in a form with no textboxes at all
3. In this case there is no textbox to satisfy the requirement for the
isnull.

Is there a way to do an ISNULL against a query. If there was someway to
check if the query returned no values then I could use that as a starting
point for the function.

Here is the update code just in case you were wondering

Private Sub Form_Close()
If IsNull(Forms![Open EFHR]![Closed]) = False Then
If Forms![Open EFHR]![Closed] = "yes" Then
DoCmd.RunMacro "Transfer Closed EFHR", 1
End If
Else
DoCmd.Close

End If
End Sub


Any other ideas? Thanks again
 

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