G
Guest
hi, i am trying to create a code where when the user presses a button,
depending on which option button is chosen the report based on a query will
be shown in ascending order by Date Set (one field) or by Date Due (another
field). so on the form i have a group of option buttons. if the first option
is selected the report will be ordered by the DAte Set field in the query,
and if hte second option button is selected the report will be sorted by the
field called Date Due. i thought the best way to do this would be to use a
select command and use the order by function. is this right ... however i am
new to coding and dont think i have done this rite .. any help would be much
appreciated.
code:
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "Homework") <>
acObjStateOpen Then
MsgBox "You must open the report first."
Exit Sub
End If
' Build user option for Sort Criteria
If SortOptionGroup.Value = "1" Then
strSort ="SELECT [*] FROM [qryHomework] ORDER BY [DateSet]"
DoCmd.RunSQL strSort
Else
strSort = "SELECT [*] FROM [qryHomework] ORDER BY [DateDue]"
DoCmd.RunSQL strSort
End If
any ideas would be welcome. thanks
depending on which option button is chosen the report based on a query will
be shown in ascending order by Date Set (one field) or by Date Due (another
field). so on the form i have a group of option buttons. if the first option
is selected the report will be ordered by the DAte Set field in the query,
and if hte second option button is selected the report will be sorted by the
field called Date Due. i thought the best way to do this would be to use a
select command and use the order by function. is this right ... however i am
new to coding and dont think i have done this rite .. any help would be much
appreciated.
code:
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "Homework") <>
acObjStateOpen Then
MsgBox "You must open the report first."
Exit Sub
End If
' Build user option for Sort Criteria
If SortOptionGroup.Value = "1" Then
strSort ="SELECT [*] FROM [qryHomework] ORDER BY [DateSet]"
DoCmd.RunSQL strSort
Else
strSort = "SELECT [*] FROM [qryHomework] ORDER BY [DateDue]"
DoCmd.RunSQL strSort
End If
any ideas would be welcome. thanks