Is it possible to create a command button on a form that will allow you to
sort records or to use the Filter by Selction option? They are not choices I
can select while using the wizard or the macro builder. However, both of
these would be extremely useful as I'm building a database for someone who
has never used a database before and isn't all that comfortable with
computers in general.
I am using Access 2003 and I am NOT familiar with Access Visual Basic, Java
or building macros from scratch. I'm sure there is a way to use these tools
to create what I want, but I don't know how to do it. Help?
|
|
0
|
|
|
|
Reply
|
Utf
|
2/2/2010 8:49:01 PM |
|
On Tue, 2 Feb 2010 12:49:01 -0800, areker <areker@discussions.microsoft.com>
wrote:
>Is it possible to create a command button on a form that will allow you to
>sort records or to use the Filter by Selction option? They are not choices I
>can select while using the wizard or the macro builder. However, both of
>these would be extremely useful as I'm building a database for someone who
>has never used a database before and isn't all that comfortable with
>computers in general.
>
>I am using Access 2003 and I am NOT familiar with Access Visual Basic, Java
>or building macros from scratch. I'm sure there is a way to use these tools
>to create what I want, but I don't know how to do it. Help?
The button would in fact use VBA (Visual Basic for Applications) within
Access.
The exact code would depend on your table structure and what it is that you
want to do. If you're going to do sorting or filtering, you must somehow
determine which fields to sort by and/or to search! If you could describe your
table structure (relevant fieldnames and datatypes), and a bit more about just
what you want this button to do, someone should be able to help... but to have
"Click this button to sort the data in the way I'm thinking of" requires the
telepathic interface, which won't be out until the release of Access
20<mmf><choke><sputter>
--
John W. Vinson [MVP]
|
|
0
|
|
|
|
Reply
|
John
|
2/2/2010 10:11:46 PM
|
|
Thank you for replying to my Access Database question. I can't attach it
here, but I have a printscreen of the fields and datatypes I'm working with
in the table so far. I can email this to you or anyone else who might have
an answer.
Maybe what I am asking for isn't possible, I don't know. I would like for
her to be able to either sort or filter-by-selection (a separate command
button for each) not based so much on telepathy *smile* but on whatever field
she places her cursor in. This is how it works if you're using the menu
buttons across the top. If you're creating the command button with VBA code,
can you ask it to choose the appropriate field to sort or filter on based
solely on where the cursor is located, or are you limited to building the
command button using only one specific pre-determined field?
|
|
0
|
|
|
|
Reply
|
Utf
|
2/3/2010 7:54:01 PM
|
|
On Wed, 3 Feb 2010 11:54:01 -0800, areker <areker@discussions.microsoft.com>
wrote:
>
>Thank you for replying to my Access Database question. I can't attach it
>here, but I have a printscreen of the fields and datatypes I'm working with
>in the table so far. I can email this to you or anyone else who might have
>an answer.
>
>Maybe what I am asking for isn't possible, I don't know. I would like for
>her to be able to either sort or filter-by-selection (a separate command
>button for each) not based so much on telepathy *smile* but on whatever field
>she places her cursor in. This is how it works if you're using the menu
>buttons across the top. If you're creating the command button with VBA code,
>can you ask it to choose the appropriate field to sort or filter on based
>solely on where the cursor is located, or are you limited to building the
>command button using only one specific pre-determined field?
>
Well, the problem is that when you click a button on a control... *that button
has the focus*. You can use the Screen.PreviousControl method to see which
control previously had the focus. I'm imagining code like:
Private Sub cmdSort_Click()
Dim strControlsource As String
strControlsource = Screen.PreviousControl.ControlSource
Me.OrderBy = strControlsource
Me.OrderByOn = True
However, this will need some fairly elaborate error checking: check for
Err.Number = 2483 (there was no previous control), or other error numbers (if
the control source is an expression or something other than a fieldname, or if
the previous control was some object which doesn't HAVE a controlsource).
Good luck!
--
John W. Vinson [MVP]
|
|
0
|
|
|
|
Reply
|
John
|
2/3/2010 10:03:42 PM
|
|
|
3 Replies
1470 Views
(page loaded in 0.017 seconds)
Similiar Articles: Command Button to Sort and Filter by Selection - microsoft.public ...Is it possible to create a command button on a form that will allow you to sort records or to use the Filter by Selction option? They are not choic... Remove sort and filters programmatically on form - microsoft ...Command Button to Sort and Filter by Selection - microsoft.public ... Command Button to Sort and Filter by Selection - microsoft.public ... Remove sort and filters ... Command button to filter list box - microsoft.public.access.forms ...Command Button to Sort and Filter by Selection - microsoft.public ... Is it possible to create a command button on a form that will allow you to sort records or to use the ... Command Button Wizard - microsoft.public.access.formscoding ...Command Button to Sort and Filter by Selection - microsoft.public ... Command Button Wizard - microsoft.public.access.formscoding ... Command Button to Sort and Filter by ... Sorting Buttons (VBA) - microsoft.public.access.formsCommand Button to Sort and Filter by Selection - microsoft.public ... Sorting Buttons (VBA) - microsoft.public.access.forms Command Button to Sort and Filter by Selection ... Delete command button in Access - microsoft.public.access ...Command Button to Sort and Filter by Selection - microsoft.public ... Delete command button in Access - microsoft.public.access ... Command Button to Sort and Filter by ... Create button to sort records - microsoft.public.access.forms ...Command Button to Sort and Filter by Selection - microsoft.public ... Is it possible to create a command button on a form that will allow you to sort records or to use the ... Toggle button vs Command button - microsoft.public.access.forms ...Toggle Button Reset - microsoft.public.access Command Button to Sort and Filter by Selection - microsoft.public ... changing toggle button via VBA - microsoft.public.access ... Reset Filter Selection (All) On Pivot Table Form - microsoft ...apply filter macro - microsoft.public.access.forms Hi, I am trying to filter a pivot table through ... Command Button to Sort and Filter by Selection - microsoft.public ... changing toggle button via VBA - microsoft.public.access ...Toggle button vs Command button - microsoft.public.access.forms ... Command Button to Sort and Filter by Selection - microsoft.public ... changing toggle button via VBA ... Command Button to Sort and Filter by Selection - microsoft.public ...Is it possible to create a command button on a form that will allow you to sort records or to use the Filter by Selction option? They are not choic... Command Button to Sort and Filter by Selection DataBaseIs it possible to create a command button on a form that will allow you to sort records or to use the Filter by Selction option? They are not choices I can select ... Filtering and Sorting Data in Forms and Reports - Casa de Bender... can reapply the last filter saved by clicking the Apply Filter button ... whenever a user chooses the Apply Filter/Sort, Remove Filter/Sort, or Filter By Selection command, and ... Filter By Selection Command Button - dBforumsIf this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to ... Chapter 3: Using Forms to Collect, Filter, and Display InformationCustomizing a Command Button Created with a Wizard ... occurs whenever a user chooses the Apply Filter/Sort, Remove Filter/Sort, or Filter By Selection command, and ... 7/23/2012 3:33:01 AM
|