Passing an autonumber to a subform

supportt

Registered User.
Local time
Today, 23:42
Joined
Nov 21, 2001
Messages
70
I have three forms, HOTSHOTS_WORKSHEET, HOTSHOTS_ADDENDUM and INVOICE, I have the HOTSHOTS_WORKSHEET Form setup to generate a unique number in the field called PRO_HSTA. I would like to pass that number and open the subforms when I save the original record. I am using Access XP, also, I am new to access, so if someone could provide some simple steps to complete this, it would be very much appreciated.
Thanks
David
 
If your subforms are embedded in your main form, the links should update the child link field in the subform.

If you are opening the subsequent forms in separate windows, you might try using the "gotfocus" event of the first control in the secondary form. For instance:

If IsNull(Me!Record_ID) Then
Me!Record_ID = Forms![frm_HOTSHOTS_WORKSHEET]![PRO_HSTA]
Else
End If

Where "Me!Record_ID" is the place to store the unique identifier in the ADDENDUM or INVOICE forms. This way the PRO_HSTA number is only pulled into the other form if there is nothing in the form (as in a data entry form). But if there is data already there, nothing will be overwritten.

This is a method I use, probably not the simplest method...

Matt
 
Hey Matthew- My sub forms are not embedded in my main form, I have buttons on the main form to access the sub forms. I added the following behind the save button on the main form to gotfocus :



If IsNull(PRO_HSTA) Then

PRO_HSTA = Forms![frm_HOTSHOTS_WORKSHEET]![PRO_HSTA]

Else

End If



PRO_HSTA is my unique autonumber field…..Not sure what is was suppose to do????? Bare with me, I am new to Access



I do appreciate the HELP!



My User name on www.access-programmers.com.uk is supportt
 
If you enter this in your HOTSHOTS_WORKSHEET form Access will probably tell you that you can't assign a value to an autonumber field. Try it in either the ADDENDUM or INVOICE forms. I usually put the code in the focus event of the first control. The field you're trying to put the PRO_HSTA value into cannot be an autonumber, but should be Long Integer to match the number format.

So: you press the button on your main form; this loads your ADDENDUM form; in the ADDENDUM form either an event of the form itself or one of the controls checks to see if there is a value in the appropriate field; if not, then the PRO_HSTA value from the main field is pulled over and placed in the ADDENDUM or INVOICE form.

Hope this helps,

Matt
 

Users who are viewing this thread

Back
Top Bottom