u0028854
Jul 13th, 2004, 05:57 PM
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.
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.