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

Row Source Code not working on SubForm 2

Status
Not open for further replies.

WallT

Vendor
Aug 13, 2002
247
US
I have the following code under a ComboBox rowsource in a SubForm. However, it won't work when I have the form open as a SubForm. It will only work when the SubForm is open by itself. Where and what do I put to let this know it's on a Sub...HELP!

SELECT tblEntities.ServiceAddress, tblEntities.PartyBeingServed FROM tblEntities WHERE (((tblEntities.PartyBeingServed)=[Forms]![frmNewOrderSub]![txtPartyBeingServed]));
 
When you change a form to a sub-form, you have to re-qualify any references to the form.

For example, the form object corresponding to form 'X' when form X is a stand-alone form is:
Forms("X")
If form 'X' is a subform of form 'Y', you would use
Forms("Y")("X")

Following is some code that you can invoke using, say, an Autokeys macro and a message box to show the fully qualified name of any control:

' get the current active control (the one that has focus)
Dim CurActiveControl As Control
Set CurActiveControl = Nothing
Set CurActiveControl = Screen.ActiveControl
If CurActiveControl Is Nothing Then Exit Function

' build a fully-qualified control name based on the object hierarchy of the
' current active control
Dim FullyQualifiedControlName As String
FullyQualifiedControlName = ""

Dim MyObject As Object
Set MyObject = CurActiveControl

Do While True
FullyQualifiedControlName = "(""" & MyObject.Name _
& """)" & FullyQualifiedControlName
If MyObject.Parent Is Nothing Then Exit Do
Set MyObject = MyObject.Parent
Loop
FullyQualifiedControlName = "Forms" & _
FullyQualifiedControlName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top