Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page