wlwebb
asked on
MS Access - Docmd.Openform pass a variable
Hello all!
Using MS Access 07
I have a Form where if the user clicks a control button I have it Open a 2nd form.
On that 2nd Form there are two Unbound combo boxes that the user selects a State or County to filter info on that 2nd form.
That same State and County had already selected on the 1st Form (also in unbound combo boxes) before they clicked on the control button.
The 2nd Form is Not a subform of the 1st. It is an independent form.
On both Forms the Unbound State combo box is named "cboSelectState" and the Unbound County combo box is named "cboSelectCounty"
My OnClick event on the 1st Form is
It opens the Form correctly but it doesn't update those two combo boxes on the 2nd from with the info I'm trying to pass to it.
Using MS Access 07
I have a Form where if the user clicks a control button I have it Open a 2nd form.
On that 2nd Form there are two Unbound combo boxes that the user selects a State or County to filter info on that 2nd form.
That same State and County had already selected on the 1st Form (also in unbound combo boxes) before they clicked on the control button.
The 2nd Form is Not a subform of the 1st. It is an independent form.
On both Forms the Unbound State combo box is named "cboSelectState" and the Unbound County combo box is named "cboSelectCounty"
My OnClick event on the 1st Form is
Private Sub cmdAddStateCountyBkType_Click()
Dim lngState As Long, lngCountyCode As Long
lngState = Me.cboSelectState.Column(0)
lngCountyCode = Me.cboSelectCounty.Column(0)
DoCmd.OpenForm "frmSys_ValidCountyCodeBookType", , "[cboSelectState]=" & lngState & "," & "[cboSelectCounty]=" & lngCountyCode
End Sub
It opens the Form correctly but it doesn't update those two combo boxes on the 2nd from with the info I'm trying to pass to it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, my .NET is showing :)
Change that line to this:
If InStr(1, Me.OpenArgs, ";") > 0 Then
Change that line to this:
If InStr(1, Me.OpenArgs, ";") > 0 Then
ASKER
Mbiz....
That works for passing the State.....
However, on the County it isn't working. That's because my combo box rowsource for the County is updated from the AfterUpdate event of the cboSelectState combo box.....
Since the Rowsource isn't within the Rowsource of that combobox but is in the VB code can I get there?
That works for passing the State.....
However, on the County it isn't working. That's because my combo box rowsource for the County is updated from the AfterUpdate event of the cboSelectState combo box.....
Since the Rowsource isn't within the Rowsource of that combobox but is in the VB code can I get there?
ASKER
LSM....
Well that works for the State, but like my response to Mbiz just above, my Rowsource code for the SelectCounty combobox is in VB code of the AfterUpdate event of the SelectState...... so the passing of that argument doesn't see any rowsource....
Is there a way around?
Well that works for the State, but like my response to Mbiz just above, my Rowsource code for the SelectCounty combobox is in VB code of the AfterUpdate event of the SelectState...... so the passing of that argument doesn't see any rowsource....
Is there a way around?
ASKER
NEVER MIND..........
Got it.... I just copy and inserted the "SELECT" code for the RowSource from the CboSelectState just before the "me.cboselectCounty = arr(1)" coding
Got it.... I just copy and inserted the "SELECT" code for the RowSource from the CboSelectState just before the "me.cboselectCounty = arr(1)" coding
ASKER
Thanks LSM and MBiz.......
I tried both methods and they both worked!!!!!!! I gave you each equal amounts of points because both worked and both were posted extremely quickly after I posted the question
THANK YOU
I tried both methods and they both worked!!!!!!! I gave you each equal amounts of points because both worked and both were posted extremely quickly after I posted the question
THANK YOU
ASKER
I get a Run-Time Error "5"
Invalid procedure call or argument.
it's stopping on
If InStr(0, Me.OpenArgs, ";") > 0 Then
when I hover over the "OpenArgs" in the first line I do see the correct cbo codes from the 1st form...... ????