Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2008, 09:37 AM
Registered User
 
Join Date: Nov 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form-Subform-2ndSubForm question...

I have a subform with a combo. The uses selects a choice. On the 2nd subform, embedded in the first subform, I have another combo box. I want the Row Source on the 2nd subform to load from one of 3 lookup tables. I'm sure this is simple but I think that the problem that I am having is proper referencing in my IF statement. I have the IF statement tied to the After Update event on the 1st combo box.

I am using Access 2003.

Any help or direction will be appreciated.

Papa

 
Old November 12th, 2008, 06:04 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hard to see what's wrong with the if statement when it's not included.
Making the assumption that the name of the child object on the first subform is Second_Child and you want to change which field is used by the value of the first combo so the second combo would show values from that field in the same table then the code would be something like this:
---------------------------------------------------------------------------
Private Sub First_Combo_AfterUpdate()

  Dim sSource As String
  If First_Combo.Value = "" _
    Then sSource = "<Desired Default Select>" _
    Else sSource = "Select " & First_Combo.Value & " From Table1 Order By " & First_Combo
  Second_Child.Form.Second_Combo.RowSource = sSource

End Sub
---------------------------------------------------------------------------

Hope this helps,
Al

 
Old November 18th, 2008, 12:51 AM
Registered User
 
Join Date: Nov 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Al:

Here is the code that I've tried.
Parent form: frmParkInfoZone
1st child form: sbfZone4Areas; cboArea
2nd child form: ssubZone4; cboDetail

The choice of Area (4 different areas) will change the Detail combo box Record Source

Thanks for taking a look & your response,

Papa

==============

Private Sub cboArea_AfterUpdate()

    'reset detail list based on Area choice
    If Me.cboArea = "Main St." Then
        Me![frmParkInfoZone4]![sbfZone4Areas]! _
           [ssubZone4]![cboDetail].RecordSource = "qryDetailZ4MainSt"
    ElseIf Me.cboArea = "Windows." Then
        [ssubZone]![cboDetail] = "qryDetailZ4Windows"
    End If
End Sub



 
Old November 21st, 2008, 09:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Private Sub cboArea_AfterUpdate()

    'reset detail list based on Area choice
    Select Case Me.cboArea
        Case "Main St."
            Me.ssubZone4.Form.cboDetail.RecordSource = "qryDetailZ4MainSt"
        Case "Windows."
            Me.ssubZone4.Form.cboDetail.RecordSource = "qryDetailZ4Windows"
        Case "Your Third Choice (you said four)"
            Me.ssubZone4.Form.cboDetail.RecordSource = "qryDetailZ4Choice3"
        Case Else
            Me.ssubZone4.Form.cboDetail.RecordSource = "qryDetailZ4Choice4"
    End Select

End Sub
 
Old November 21st, 2008, 09:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

I fixed a typo in my last post.

Note that you seem to have four queries that may do the same thing but are based on the choice of area. You may not need to do this. You should probably have ONE query that accepts the value of the combobox and runs using that value.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Subform data sheet view question amob005 Access 1 December 5th, 2006 09:13 AM
Printing a form with a subform in it jcalfg Access 1 July 25th, 2006 03:40 PM
Open a subform from a form Vision G Access 5 May 13th, 2006 04:21 AM
Cant print when the form become subform yikchin Access 6 November 22nd, 2005 10:22 PM
form/subform reference tmc Access 1 August 7th, 2004 04:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.