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

Row source queries referencing incorrectly

Status
Not open for further replies.

NeedsHelp101

Technical User
Jul 18, 2006
43
US
Hello,
I made an option group ToggleFrame with 4 buttons, and wrote code so that when a button was pressed, it would change the row source of a combo box Combo1.
The problem is, I think, that the combo box is on a subform (Sub_Form), while the option group is on the main form. I did it like this to save space (which I need), but am running into the error: Microsoft Access can't find the form 'Sub_Form' in a macro expression or Visual Basic code.'
Code:
Private Sub ToggleFrame_AfterUpdate()

Dim Combo1 As ComboBox
Set Combo1 = Forms!Sub_Form.Combo1

If ToggleFrame = 1 Then
        Combo1.RowSource = "qryNotSpanTV"
    End If
    If ToggleFrame = 2 Then
        Combo1.RowSource = "qryNotSpanRadio"
    End If
    If ToggleFrame = 3 Then
        Combo1.RowSource = "qrySpanTV"
   End If
   If ToggleFrame = 4 Then
        Combo1.RowSource = "qrySpanRadio"
    End If

End Sub

Is there any way around putting the control and the cbo box on the same form?
Thanks!
 
Try this...

Code:
Me.Sub_Form.Controls("Combo1").RowSource = ...
 
Hi!

The general syntax for referencing a control on a subform is :

Me!SubformControlName.Form!ControlName.Property or

Forms!MainFormName!SubformControlName.Form!ControlName.Property

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top