Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Sorting Buttons on Form

Discussion in 'Information Technology' started by Coleman, Jul 28, 2006.

  1. Coleman

    Coleman
    Expand Collapse
    Guest

    I have a two column form that I wish to allow the user to sort by a File's
    Index number or by a File's Name. I have assigned a button to each column
    and the following code to enable an ascending order on click:

    Button #1 looks like this:
    __________________________________________________
    Private Sub Sort_By_File_Index_Click()
    On Error GoTo Err_Sort_By_File_Index_Click

    strFileIndex#.SetFocus
    DoCmd.RunCommand acCmdSortAscending

    Exit_Sort_By_File_Index_Click:
    Exit Sub

    Err_Sort_By_File_Index_Click:
    MsgBox Err.Description
    Resume Exit_Sort_By_File_Index_Click

    End Sub
    _________________________________________________

    and Button #2 looks similarly like this:
    _________________________________________________
    Private Sub Sort_By_File_Name_Click()
    On Error GoTo Err_Sort_By_File_Name_Click

    strFileName.SetFocus
    DoCmd.RunCommand acCmdSortAscending

    Exit_Sort_By_File_Name_Click:
    Exit Sub

    Err_Sort_By_File_Name_Click:
    MsgBox Err.Description
    Resume Exit_Sort_By_File_Name_Click

    End Sub
    _______________________________________________

    My problem is when I click on Button #1, I get "Complie Error: Invalid
    Qualifier", yet Button #2 works fine....and YES, the control name
    "strFileIndex#" is correct.

    Any ideas???????

    Thanks,
    Coleman
     
  2. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    If the field name includes characters other than A-Z, 1-9, or underscore,
    you must enclose it in square brackets.

    Try:
    Me.[strFileIndex#].SetFocus

    (The "Me." is optional, but helps identify what you are talking about.)

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Coleman" <Coleman@discussions.microsoft.com> wrote in message
    news:2874CB45-9CA1-461C-BA1D-BFF10B747594@microsoft.com...
    >I have a two column form that I wish to allow the user to sort by a File's
    > Index number or by a File's Name. I have assigned a button to each column
    > and the following code to enable an ascending order on click:
    >
    > Button #1 looks like this:
    > __________________________________________________
    > Private Sub Sort_By_File_Index_Click()
    > On Error GoTo Err_Sort_By_File_Index_Click
    >
    > strFileIndex#.SetFocus
    > DoCmd.RunCommand acCmdSortAscending
    >
    > Exit_Sort_By_File_Index_Click:
    > Exit Sub
    >
    > Err_Sort_By_File_Index_Click:
    > MsgBox Err.Description
    > Resume Exit_Sort_By_File_Index_Click
    >
    > End Sub
    > _________________________________________________
    >
    > and Button #2 looks similarly like this:
    > _________________________________________________
    > Private Sub Sort_By_File_Name_Click()
    > On Error GoTo Err_Sort_By_File_Name_Click
    >
    > strFileName.SetFocus
    > DoCmd.RunCommand acCmdSortAscending
    >
    > Exit_Sort_By_File_Name_Click:
    > Exit Sub
    >
    > Err_Sort_By_File_Name_Click:
    > MsgBox Err.Description
    > Resume Exit_Sort_By_File_Name_Click
    >
    > End Sub
    > _______________________________________________
    >
    > My problem is when I click on Button #1, I get "Complie Error: Invalid
    > Qualifier", yet Button #2 works fine....and YES, the control name
    > "strFileIndex#" is correct.
    >
    > Any ideas???????
    >
    > Thanks,
    > Coleman
     
  3. fredg

    fredg
    Expand Collapse
    Guest

    On Mon, 10 Jul 2006 09:23:02 -0700, Coleman wrote:

    > I have a two column form that I wish to allow the user to sort by a File's
    > Index number or by a File's Name. I have assigned a button to each column
    > and the following code to enable an ascending order on click:
    >
    > Button #1 looks like this:
    > __________________________________________________
    > Private Sub Sort_By_File_Index_Click()
    > On Error GoTo Err_Sort_By_File_Index_Click
    >
    > strFileIndex#.SetFocus
    > DoCmd.RunCommand acCmdSortAscending
    >
    > Exit_Sort_By_File_Index_Click:
    > Exit Sub
    >
    > Err_Sort_By_File_Index_Click:
    > MsgBox Err.Description
    > Resume Exit_Sort_By_File_Index_Click
    >
    > End Sub
    > _________________________________________________
    >
    > and Button #2 looks similarly like this:
    > _________________________________________________
    > Private Sub Sort_By_File_Name_Click()
    > On Error GoTo Err_Sort_By_File_Name_Click
    >
    > strFileName.SetFocus
    > DoCmd.RunCommand acCmdSortAscending
    >
    > Exit_Sort_By_File_Name_Click:
    > Exit Sub
    >
    > Err_Sort_By_File_Name_Click:
    > MsgBox Err.Description
    > Resume Exit_Sort_By_File_Name_Click
    >
    > End Sub
    > _______________________________________________
    >
    > My problem is when I click on Button #1, I get "Complie Error: Invalid
    > Qualifier", yet Button #2 works fine....and YES, the control name
    > "strFileIndex#" is correct.
    >
    > Any ideas???????
    >
    > Thanks,
    > Coleman


    It's the use of the # symbol in the field name.
    The # is a date delimiter symbol and your use of one here in the
    control name is causing a compile error.

    Either change the field name to something else, i.e. strFileNo or
    enclose the field name in brackets, i..e [strFile#].SetFocus
    Also make sure the control is Enabled.
    --
    Fred
    Please respond only to this newsgroup.
    I do not reply to personal e-mail
     
  4. Coleman

    Coleman
    Expand Collapse
    Guest

    Thanks for the feedback...Yes, I see what you are saying about the use of the
    "#" sign...total overlook on my part, but I'm saved by the brackets.

    Thanks again..
    CH

    "fredg" wrote:

    > On Mon, 10 Jul 2006 09:23:02 -0700, Coleman wrote:
    >
    > > I have a two column form that I wish to allow the user to sort by a File's
    > > Index number or by a File's Name. I have assigned a button to each column
    > > and the following code to enable an ascending order on click:
    > >
    > > Button #1 looks like this:
    > > __________________________________________________
    > > Private Sub Sort_By_File_Index_Click()
    > > On Error GoTo Err_Sort_By_File_Index_Click
    > >
    > > strFileIndex#.SetFocus
    > > DoCmd.RunCommand acCmdSortAscending
    > >
    > > Exit_Sort_By_File_Index_Click:
    > > Exit Sub
    > >
    > > Err_Sort_By_File_Index_Click:
    > > MsgBox Err.Description
    > > Resume Exit_Sort_By_File_Index_Click
    > >
    > > End Sub
    > > _________________________________________________
    > >
    > > and Button #2 looks similarly like this:
    > > _________________________________________________
    > > Private Sub Sort_By_File_Name_Click()
    > > On Error GoTo Err_Sort_By_File_Name_Click
    > >
    > > strFileName.SetFocus
    > > DoCmd.RunCommand acCmdSortAscending
    > >
    > > Exit_Sort_By_File_Name_Click:
    > > Exit Sub
    > >
    > > Err_Sort_By_File_Name_Click:
    > > MsgBox Err.Description
    > > Resume Exit_Sort_By_File_Name_Click
    > >
    > > End Sub
    > > _______________________________________________
    > >
    > > My problem is when I click on Button #1, I get "Complie Error: Invalid
    > > Qualifier", yet Button #2 works fine....and YES, the control name
    > > "strFileIndex#" is correct.
    > >
    > > Any ideas???????
    > >
    > > Thanks,
    > > Coleman

    >
    > It's the use of the # symbol in the field name.
    > The # is a date delimiter symbol and your use of one here in the
    > control name is causing a compile error.
    >
    > Either change the field name to something else, i.e. strFileNo or
    > enclose the field name in brackets, i..e [strFile#].SetFocus
    > Also make sure the control is Enabled.
    > --
    > Fred
    > Please respond only to this newsgroup.
    > I do not reply to personal e-mail
    >
     

Share This Page