Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

entering data in subform before a parent pops up a message

Status
Not open for further replies.

maxminh

Programmer
Apr 7, 2010
8
0
0
US
Greetings!

Here is my situation. I have two forms in a parent and child
relationship, with the child form contained in the parent.
When the forms first open up, they are blanked for data entry.
If I try to enter some data into the child form, before entering any data into the parent a message box would pop up saying

"You tried to assign the Null value to a variable that is not a variant data type."

Once I pressed ok, I can continue entering the data like normal.

My question is how can I prevent this message box from popping up in the first place?
 
To clarify, what I meant to say is enter the child data fist into the subform without creating a record for it. Just entering data into the subform pop up the message.

Why would people enter data into the subform first?

Some one who knows how the tables are related would probably never enter the child record first. To an average user who would be using a form containing both parent and child fields to enter data, it is not clear which fields belong to which table. I would like to take this situation into account and either suppress the pop up message or capture and give a pop up message of my own with instructions on entering data.

 
I believe you can capture the error in the FORM error event. I have had lots of what I consider "average" users and don't recall users entering child records prior to entering the parent record.

I suppose you could hide or disable the subform until a record is saved in the main form recordsource. This would remove the issue all together.

Duane
Hook'D on Access
MS Access MVP
 
Thanks Duane!

It turns out, I was able to catch the error in the subform error event.
 
On further testing, the on error capture event did not work.
The other possibility was to locked or hide the subform until data is entered into the form does work, but not what I required.

One way that work was to synchronize the parent and child form by VBA code, this prevented the pop message from occurring.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top