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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoNumber problem

Status
Not open for further replies.

soklear

IS-IT--Management
Jan 13, 2004
38
US
Hi. My question is regarding a form that has an autonumber field that doesnt populate until data is entered on the form.

Is there a way to force the autonumber to populate immediately when the form is opened? The reason being is that there is a sub-form that is linked to the 'uniqueid' field of the main form. When a user goes to the sub-form and enters data before populating the main form, and then clicks out of the sub-form - all the data is lost that was just entered (because of the UniqueID field being linked).

Ive tried a docmd.save and other methods but just cant seem to get it right.

Any help would be appreciated.

Thanks.
Bob
 
Would it not be more natural, and safer, to force the user to complete a relevant main form field before entering data in the subform?
 
How are ya soklear . . .

The rule is: [blue]You can't enter data in a child table without a matching link ID field in the parent table.[/blue]

If your entering data in the subform 1st then there's something wrong with your table structure! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
On both points. Absolutely.

I have attempted to 'lock' the subform until at least one field (say, the vendor name) is inserted. I am not experienced with VBA so, I may have done something wrong.

Secondly, the matching id (UniqueID) from the first table is the matching link id on the subform. The problem is that, the matching link ID is a primary key called workerorder number on the parent form and the secondary table uses this field to link between the two.

 
How did you try to lock the subform? You could use the On Enter event of the subform control to check the main form.
 
I believe i just used the on focus event. I will try that and let you know.

-Bob
 
You could set the subform to enabled = false and then play with something like:
if me.dirty then
subform.enabled = true
end if

Hope this helps.

"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
 
The 'On Enter' worked like a champ.

Thanks for all your help, especially, Remou.

-Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top