G
Gina Whipp
Hello All,
Not sure why this won't work and I'm hoping someone can steer me in the
right direction. The code located below is on the main form; at the bottom
is the recordsource for the subform which won't open following the OrderBy.
It opens sorting another field located on the form. Can someone explain why
it won't follow my 'ORDER BY tblGroceryItems.giItem' on open of the main
form. Thanks, in advance.
Dim MySQL As String, MyCriteria As String, MyRecordSource As String
Dim FieldValue As String, Tmp As Variant
' Initialize SELECT statement.
MySQL = "SELECT * FROM tblGroceryItems WHERE "
MyCriteria = "" & "ORDER BY tblGroceryItems.giItem"
FieldValue = [txtlookfor]
'Create criteria for WHERE clause.
If FieldValue <> "" Then
MyCriteria = ("[giItem]" & " Like " & Chr(39) & Chr(42) & FieldValue
& Chr(42) & Chr(39)) & "ORDER BY tblGroceryItems.giItem"
Else
MyCriteria = "True ORDER BY tblGroceryItems.giItem"
End If
' Create SELECT statement.
MyRecordSource = MySQL & MyCriteria
' Set RecordSource property of Form.
Forms![frmMakeList].[sfrList].Form.RecordSource = MyRecordSource
Forms![frmMakeList].[sfrList].SetFocus
Not sure why this won't work and I'm hoping someone can steer me in the
right direction. The code located below is on the main form; at the bottom
is the recordsource for the subform which won't open following the OrderBy.
It opens sorting another field located on the form. Can someone explain why
it won't follow my 'ORDER BY tblGroceryItems.giItem' on open of the main
form. Thanks, in advance.
Dim MySQL As String, MyCriteria As String, MyRecordSource As String
Dim FieldValue As String, Tmp As Variant
' Initialize SELECT statement.
MySQL = "SELECT * FROM tblGroceryItems WHERE "
MyCriteria = "" & "ORDER BY tblGroceryItems.giItem"
FieldValue = [txtlookfor]
'Create criteria for WHERE clause.
If FieldValue <> "" Then
MyCriteria = ("[giItem]" & " Like " & Chr(39) & Chr(42) & FieldValue
& Chr(42) & Chr(39)) & "ORDER BY tblGroceryItems.giItem"
Else
MyCriteria = "True ORDER BY tblGroceryItems.giItem"
End If
' Create SELECT statement.
MyRecordSource = MySQL & MyCriteria
' Set RecordSource property of Form.
Forms![frmMakeList].[sfrList].Form.RecordSource = MyRecordSource
Forms![frmMakeList].[sfrList].SetFocus