I have an option group control with 2 choices:
Sort ASC and Sort DESC
When this choice is made, I want to change the recordsource for the
current form and do a refresh so it sorts that data in the order
specified by the option group.
When it gets to the line Me.Recordsource" it errors out with "Object
cannot sup****t this property or method."
I've already tried:
Forms!frmMyformName.setfocus (prior to changing the recordsource) as
well as:
Forms!frmMyformName.recordsource = "Select * from..." and that does not
work either."
When I am in a subroutine for ControlX that exists on FormX, what is the
proper syntax for changing FormX's recordsource and doing a refresh of
the form while ControlX inside that form has the focus?
(here's the code so far)
Private Sub optSortMethod2_Click()
On Error GoTo Err1
Dim strSortBy As String
Dim strSelect As String
cmbSort.SetFocus
strSortBy = "order by " & cmbSort.Text
Select Case optSortMethod2.Value
Case 1
strSortBy = strSortBy & " Asc"
Case 2
strSortBy = strSortBy & " Desc"
Case Else
'do nothing here
End Select
Me.RecordSource = "Select * from tblMyTable where DATEREC BETWEEN #" &
lblFromDate & "# AND #" & lblToDate & "#" & strSortBy
' Forms!frmHistory.SetFocus
' Forms!frmHistory.RecordSource = "Select * from tblMyTable where
DATEREC BETWEEN #" & lblFromDate & "# AND #" & lblToDate & "#" &
strSortBy
' Me.Refresh
Exit1:
Exit Sub
Err1:
MsgBox Err.Number & "-" & Err.DESCRIPTION, vbOKOnly, gblPgmTitle &
gblPgmErrorTag & "-optSortMethod2_Click()"
Resume Exit1
End Sub
*** Sent via Developersdex http://www.developersdex.com
***