Re: Subform won't sort properly

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ken Snell [MVP] (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 01/15/05


Date: Sat, 15 Jan 2005 17:34:37 -0500

Assuming that this is a copy/paste of your real code:

"Gina Whipp" <NotInterested@InViruses.com> wrote in message
news:Or1fxt0%23EHA.1936@TK2MSFTNGP10.phx.gbl...
> 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
>
>
> --
> Gina Whipp
>



Relevant Pages

  • Subform wont sort properly
    ... Not sure why this won't work and I'm hoping someone can steer me in the ... It opens sorting another field located on the form. ... Dim MySQL As String, MyCriteria As String, MyRecordSource As String ...
    (microsoft.public.access.queries)
  • Re: Subform wont sort properly
    ... setting the RecordSource On Open! ... It opens sorting another field located on the form. ... > Dim MySQL As String, MyCriteria As String, MyRecordSource As String ...
    (microsoft.public.access.queries)
  • Re: finding how much the file system is full, from a C program?
    ... If string is a null pointer, the system function determines whether the host ... The fopen function opens the file whose name is the string pointed to by filename, and associates a stream with it. ... wb truncate to zero length or create binary file for writing ...
    (comp.lang.c)
  • Re: Command button to open form and find record
    ... Opens the form if it is not already open. ... Public Function OpenFormTo(strForm As String, strWhere As String, Optional bGotoNewRecord As Boolean, _ ... Optional strOpenArgs As String) As Boolean ... Public Function HasProperty ...
    (microsoft.public.access.forms)
  • OpenForm error: Access 2007/2010
    ... Running into a strange problem where a command button suddenly stops ... "StartStopDates_TransferOpenFirst" normally opens. ... Dim ServerMoorefield As String ...
    (comp.databases.ms-access)