A
ArielZusya
I've got a form that, on the click of a button, closes itself and opens a new
form with a filter value passed by a previous form. The code for that looks
as follows:
Private Sub btnOpenNext_Click ()
Dim stLinkCriteria As String
Dim stFormName As String
stLinkCriteria = "RefNum = '" & me.RefNum.Value & "'"
stFormName = "frmNext"
DoCmd.CloseForm
DoCmd.OpenForm stFormName, , , stLinkCriteria
End Sub
Once on the new form I've got an option group with toggle buttons which I'd
like to use to filter the form further. I just don't want to lose my
original filter. The way I've done the toggle button option group in the
past is by changing the RecordSource to an SQL string reflecting the change I
wanted. The code would look something like:
Private Sub optFilterMyRecords_Click()
Dim stFilterSQL As String
Select Case Me!optFilterMyRecords
Case 1 'All records
stFilterSQL = "SELECT tblMain.RefNum, _
tblMain.FirstName, tblMain.LastName, _
tblMain.ID_Main FROM tblMain;"
Case 2 'Just the records with FirstName = John
stFilterSQL = "SELECT tblMain.RefNum, _
tblMain.FirstName, tblMain.LastName, _
tblMain.ID_Main FROM tblMain WHERE _
(((tblMain.FirstName)='John'));"
Case 3 'Just the records with FirstName = Jane
stFilterSQL = "SELECT tblMain.RefNum, _
tblMain.FirstName, tblMain.LastName, _
tblMain.ID_Main FROM tblMain WHERE _
(((tblMain.FirstName)='Jane'));"
End Select
Me.RecordSource = stFilterSQL
Me.Requery
End Sub
What I want is to pass that RefNum to the frmNext but then when I click one
of the toggle buttons in the option group I want that RefNum to be
incorporated into the new query. My understanding is that when I pass the
RefNum to frmNext I'm not creating a query for frmNext but instead using
RefNum as a Filter for frmNext. Is there a way to make this all work?
Thanks for your help!
form with a filter value passed by a previous form. The code for that looks
as follows:
Private Sub btnOpenNext_Click ()
Dim stLinkCriteria As String
Dim stFormName As String
stLinkCriteria = "RefNum = '" & me.RefNum.Value & "'"
stFormName = "frmNext"
DoCmd.CloseForm
DoCmd.OpenForm stFormName, , , stLinkCriteria
End Sub
Once on the new form I've got an option group with toggle buttons which I'd
like to use to filter the form further. I just don't want to lose my
original filter. The way I've done the toggle button option group in the
past is by changing the RecordSource to an SQL string reflecting the change I
wanted. The code would look something like:
Private Sub optFilterMyRecords_Click()
Dim stFilterSQL As String
Select Case Me!optFilterMyRecords
Case 1 'All records
stFilterSQL = "SELECT tblMain.RefNum, _
tblMain.FirstName, tblMain.LastName, _
tblMain.ID_Main FROM tblMain;"
Case 2 'Just the records with FirstName = John
stFilterSQL = "SELECT tblMain.RefNum, _
tblMain.FirstName, tblMain.LastName, _
tblMain.ID_Main FROM tblMain WHERE _
(((tblMain.FirstName)='John'));"
Case 3 'Just the records with FirstName = Jane
stFilterSQL = "SELECT tblMain.RefNum, _
tblMain.FirstName, tblMain.LastName, _
tblMain.ID_Main FROM tblMain WHERE _
(((tblMain.FirstName)='Jane'));"
End Select
Me.RecordSource = stFilterSQL
Me.Requery
End Sub
What I want is to pass that RefNum to the frmNext but then when I click one
of the toggle buttons in the option group I want that RefNum to be
incorporated into the new query. My understanding is that when I pass the
RefNum to frmNext I'm not creating a query for frmNext but instead using
RefNum as a Filter for frmNext. Is there a way to make this all work?
Thanks for your help!