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

Populate field on form with data from anther open form.

Status
Not open for further replies.

alan1203

Technical User
Mar 16, 2007
27
GB
Hi, I have a database for keeping track of spare parts in my department. Currently users have to enter the part information and then assign that part to a machine on another form.

The new part form has the following fields.
Part Description:
Part Number (PK)
Part Supplier
Part Price
Part Location

When the user inputs this information they then open another form using a button to assign the part to a machine.

That form has the following fields:
Machine Part ID
Machine ID
Part Number (FK)
I was wondering if there is a way to auto populate part number on this form using the part number on the first form. Both forms are open at the same time.

Thank you for any help given.
Alan
 
What is the actual VBA code of the Click event procedure of the button lauching the second form.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
WOW amazinly quick reply, Thank you.
I just used the button wizard on access so it looks like this:
Private Sub btnAssign_Click()
On Error GoTo Err_btnAssign_Click

Dim stDocName As String
Dim stPartNumber As String

DoCmd.Requery
stDocName = "frmAttachModeltoPart"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnAssign_Click:
Exit Sub

Err_btnAssign_Click:
MsgBox Err.Description
Resume Exit_btnAssign_Click

End Sub
 
If frmAttachModeltoPart is used to create new records in the MachinePart junction table you may try to play with the DefaultValue property of the relevant control.
Something like this:
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoEvents
Forms(stDocName).Controls("Part Number").DefaultValue = "=Forms![" & Me.Name & "]![Part Number]"

Another way is to use frmAttachModeltoPart as a linked subform and thus no button is needed.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I've chosen to use the frmattachmodeltopart as a linked subform. thanks for your help and your speedy replies.
Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top