invalid use of null when closing the database

  • Thread starter trevorC via AccessMonster.com
  • Start date
T

trevorC via AccessMonster.com

Hi All,
I have a problem that when i try to close my db i get an "Invalid use of
null" error.

I only get this error if i have a form open for data entry and the
application is closed without first closing the form. If the form is cloased
first and then the db is closed it all works fine.

Can i have code to act if the application is closed to check if any forms are
still open and close them first. Or is there something i can do to the form,
it's just a normal form for data entry with text and combo boxes.

regards
TrevorC
 
J

Jeanette Cunningham

Hi trevorC,
sounds like there is an error on the form, or maybe another form.
What happens with that form when you close it - are there any required
fields, what happens if they are empty.
What else does the code on that form do?
Are there filters, criteria, queries that could have a missing value?

The invalid use of null error could be to do with editing data in a form, or
it could come from trying to open something using criteria, such as another
form, from trying to close something that is no longer open, etc.

It's best to track down the error now before you dig yourself in any deeper.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
T

trevorC via AccessMonster.com

Thanks for the reply,
I have investigated this a bit more and the form will close ok by it's self,
but this causes the main menu to open. If the main menu is closed the welcome
form opens. This all happens ok manually
but if all 3 forms are open including the data entry form the error comes up.
If only the welcome and main menu forms are open it closes ok.
 
D

Dale_Fye via AccessMonster.com

Trevor,

My guess is that the data entry form is on a new record, and you have a field
that does not allow nulls, but does not have a default value. I would use
the data entry forms BeforeUpdate event to check for required fields. If a
field requires a value, and there is none, then check to see whether the user
wants to Undo the new record. If so, use the Undo method to delete the
current record. If not, display an error message and take them to the
control that is missing data.

HTH
Dale
 
J

Jeanette Cunningham

So now we know which form the error comes from.
Do a trial with this tweak - it's not permanent, just a way of finding the
error.
Comment out the code that opens the main menu when the data entry form
closes.
Now see what happens.

Does it make any difference if the data entry form is halfway through a
record when a required field is empty?

Does it make any difference if the data entry form is filled out completely
ready to save?

Does it make any difference if you comment out any code that checks for
required fields?
Do you have any table validations in the table like Is Not Null or Required
= Yes?
What happens if you temporarily remove the table validations?

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
T

trevorC via AccessMonster.com

Thanks for the update, i'll check it in more detail later today.
 

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