Results 1 to 2 of 2

Thread: Controlling drop-downs in one form base dupon the values submitted in a prior form

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    1

    Controlling drop-downs in one form base dupon the values submitted in a prior form

    For some reason, I cannot get this to work. Basically, I have a table "state" that has two fields, "state" and "region." I want to limit the values that show up in the state drop down to a specific region value.

    So, my form has only one drop-down called "State." I use the following query to populate "State:"

    SELECT State.State FROM State ORDER BY 1

    This form is accessed by first hitting a fporm where you select the given region from a drop down. The name of the drop down is "Region" and it's event looks as so:

    Private Sub LaunchStateButton_Click()
    On Error GoTo Err_LaunchStateButton_Click

    Dim stDocName As String
    Dim stArgValue As String
    Dim stOpenCriteria As String

    stDocName = "frmSelectState"

    If IsNull(Me![Combo2]) Then
    MsgBox "Please Select a Region"
    Else
    stArgValue = Me.OpenArgs & "|" & Me![Combo2]
    stOpenCriteria = "[Region]='" & Me![Combo2] & "'"
    MsgBox stOpenCriteria

    DoCmd.OpenForm stDocName, , , stOpenCriteria, , , stArgValue
    DoCmd.Close acForm, Me.Name
    End If
    Exit_LaunchStateButton_Click:
    Exit Sub

    Err_LaunchStateButton_Click:
    MsgBox Err.Description
    Resume Exit_LaunchStateButton_Click

    End Sub

    For some reason, this code simply does not work. Do I need to do anything special in either form to tie the event in the region form to the drop down in the state form?

    Needless to say, I'm a newbie to VBA and would appreciate any help I can get. Thanks.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    The form is in access??

    I'd use one form and requery the second combo list on it (whenever the first combo has changed).

    Other than that, looks ok. Is there code on the second form to filter the argument list?


    Vince
    (half asleep)

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width