Sub form linking

Malashaan

Registered User.
Local time
Today, 08:16
Joined
Jul 28, 2010
Messages
18
I have a sub form which is linked to the main form by an autonumber field, JobID. Both froms get their data from separate queries. Using this as a unique identifier I thus have the same single record visible in both forms at any given time, this is working great. However, when a new record is started although JobID automatically feeds into the main form, the JobID control on the subform remains null until I change a value of another control on the subform. This generally isn't a problem, but the subform sets default values if the user doesn't enter any - if the user elects to use all defaults then the record isn't saved as JobID was never set.

Is there a way anyone can think of of forcing the JobID control to link with the parent form as soon as a record is started? I imagine it would be VB code in the parent's on current event. I've tried requerying he subform, but as the correct link hasn't been established this just generates errors.
 
When the Main Form is opened does it have data or is this a Data Entry Form?

Where is the New Record Started?? Main Form or Sub Form?
 
It is a data entry form but pretty much every field autofills a default value on creation. The new record is created from the main form. I could just take the default value off the main list box on the subform and force the user to select something, but he (the user) is very particular about having defaults set. It seems like there must be a way to force the subform to match it's jobID autonumber control with that of the parent, I just can't make anything work,
 
When the mainform has New Data the subform doesn't update - correct?

If so, and if you close the form and open the form again with the new data displayed the subform works ok?

If this is the case then a Requery of the Mainform following data entry should resolve the issue.

To do a requery you will need to add some vba code to the after update property of a key text box control on your main form.
 
Thanks for the suggestion, it does work but doesn't fit how the guy I'm making this for wants to use it. I've taken some of the automation off to force him to enter at least one bit of data on the sub form by hand even if he wants values. Sometimes users need to be less lazy ;)
 
Did you try setting focus to one of the subforms controls?
 
Yes, the precise time that it fills the autonumber field is still unreliable - it seems the only sure way of setting it is for one of the other fields to have data entered.
 

Users who are viewing this thread

Back
Top Bottom