If 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 proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Command Button to Sort and Filter by Selection
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? |
#2
|
|||
|
|||
Command Button to Sort and Filter by Selection
On Tue, 2 Feb 2010 12:49:01 -0800, areker
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 20mmfchokesputter -- John W. Vinson [MVP] |
#3
|
|||
|
|||
Command Button to Sort and Filter by Selection
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? |
#4
|
|||
|
|||
Command Button to Sort and Filter by Selection
On Wed, 3 Feb 2010 11:54:01 -0800, areker
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] |
Thread Tools | |
Display Modes | |
|
|