Subject: referencing a subform, more complex than it sounds
Posted By: nimarii Post Date: 2/10/2004 4:22:36 PM
i'm trying to reference a subform, and i keep getting errors no matter what i try. they either can't find the subform, or the field i'm referencing.

What I'm trying to do is be able to "attach" a document on the user's machine to a table via a command button on a form. It should also be able to "Edit" existing attachments to change the name or path.

I have a button on a subform(f_orders_sub) that is linked to a text box where the attachment will show up. When the button is clicked, it will call the hyperlinkForm (completely separate form), which has a control that points to the attachment textbox. Everything works except for pointing the control to the textbox on the subform (should be marked in red)

Here's the partial code:
Option Compare Database
Option Explicit
Dim m_ctlHyperlink As Control

Private Sub form_load()
Set m_ctlHyperlink = Forms!f_order_details_form.Form.Controls(OpenArgs)
With m_ctlHyperlink.Hyperlink
    txtDisplay = .TextToDisplay
    txtAddress = .Address
    txtSubAddress = .SubAddress
End With
End Sub

Any help would be greatly appreciated!!

Reply By: nimarii Reply Date: 2/11/2004 5:35:28 PM
i found out how to do it; this is how you would refer to it:
forms!NameOfMainForm!NameOfControlThatHoldsTheSubform.form!Control
or
forms!NameOfMainForm!NameOfControlThatHoldsTheSubform.form.Property
i was confused because the control that holds the subform is not the tab that it was on, or the page it was on, but totally separate. i had to click off, then right click on the subform to get the control name, which was different from the subform name.



Go to topic 9640

Return to index page 950
Return to index page 949
Return to index page 948
Return to index page 947
Return to index page 946
Return to index page 945
Return to index page 944
Return to index page 943
Return to index page 942
Return to index page 941