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

Transfer values from subform to new form

Status
Not open for further replies.

sunmorgus

Programmer
Nov 9, 2004
81
US
Ok, here is my dilemma. I have 3 forms in question, RMA Base Form, Parts Transactions (a subform of the RMA Base Form), and frmRejectParts (a form that opens when you click a button on the Parts Transactions subform). When I click a button on the Parts Transactions subform, I need to have the frmRejectParts open and pull two values from the Parts Transactions form (part number, transaction id). I would not think this difficult, and reviewing the faq and forums have found answers on going from one form to the other; however, since I need to pull records from a subform instead of just a main form, I cannot figure how to get frmRejectParts to view the subform. (sorry if this is all confusing!)

Here is the code I am using:

(this is on the Parts Transactions subform, when you click the button to open the frmRejectParts form)

Option Compare Database
Dim strPartNumber As String

Private Sub cmdRejectPart_Click()
If MsgBox("Are you sure?", vbYesNo) = vbYes Then
If Not (IsNull(Me.Part_Number)) Then
strPartNumber = Me.Part_Number
End If
DoCmd.OpenForm "frmRejectParts", , , , acFormAdd
Else
Exit Sub
End If
End Sub

(this is the code for the frmRejectParts)

Option Compare Database

Private Sub Form_Open(Cancel As Integer)
strPartNumber = Me.Part_Number
End Sub

Any help is greatly appreciated. Thanks!
 
Hi

Not totally sure I follow, but I think you need

Private Sub Form_Open(Cancel As Integer)
strPartNumber = Forms!TheNameofthePartsform.FORM.thenameofthesubformCONTROL![Part_Number]
End Sub


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Tried that, the form that opens still cannot see and/or realize the subform is open.
 
I get this error message:

Run-Time Error - "2450":

Microsoft Access cant find the form "Parts Transactions" referred to in a macro expression or visual basic code"

When using this code On Load of frmRejectParts:

Private Sub Form_Load()
If Trim(Me.OpenArgs & "") <> "" Then
Dim frm As Form

Set frm = Forms(Me.OpenArgs)

Me.Part_Number = frm!Part_Number
'Other textbox transfers here

'Set focus to next texbox for user input
Me.Quantity.SetFocus

Set frm = Nothing
End If
End Sub

and having this in the parts transactions subform:

DoCmd.OpenForm "frmRejectParts", , , , acFormAdd, , "Parts Transactions"
 
Hi

I do not think you have read what I said

you reference the sub form via the FORM property of the form which contains the subform. As you say, the sub form is not present in the FORMS() collection

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Sorry about that, I was reading too fast.

I tried this:

Me.Part_Number = Forms![RMA Base Form].Forms.Child175.[Part Number]

but I get an error:

"Application defined, or object defined error"

is my syntax correct?
 
Me.Part_Number = Forms![RMA Base Form]!Child175.Form![Part Number]
Provided Child175 is the control hosting the form "Parts Transactions"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi

As I said

"you reference the sub form via the FORM property of the form which contains the subform. As you say, the sub form is not present in the FORMS() collection "

It is the .FORM property of the subform control

FORMS() is the collection of open forms

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top