Results 1 to 3 of 3
2010-05-04, 11:20 #1
- Join Date
- Feb 2001
- Thanked 0 Times in 0 Posts
I have a work order database that I would like to be able to display the same form with different parameters. For instance, I would like to display a form with a particular work order number (using a combox box and a command button) entered on a separate form. I may also like to see this same form with a parameters of only the work orders that I created or only the workorders that I am assigned. I currently do this with separate queries attached to separate forms (identical except for the names and the query attached). Is there a better way to do this? Its very cumbersome when I need to make a change to the form and have to do it across all the separate forms. I need to use forms, because the end user needs to be able to update the information while viewing - I can't use reports. I feel like I'm missing something really simple. Below is what I am using. Is there some way to use the same document name, yet pass a query that has the needed parameter? Any ideas? Thanks in advance for your help!
Private Sub WOViewByNumber_Click()
On Error GoTo Err_WOViewByNumber_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FRMWOView"
stLinkCriteria = "[WorkOrderNumber]=" & Me![Work Order Number]
DoCmd.OpenForm stDocName, , , stLinkCriteria
2010-05-04, 17:07 #2
- Join Date
- Mar 2004
- Manning, South Carolina
- Thanked 1,454 Times in 1,323 Posts
From your description it would seem to me that all you have to do is to add fields (user name, etc) & buttons (Work Orders Originated by Me, Work Orders Assigned to Me) to the initial form to select the necessary criteria for the filter and replicate the code above for each button substituting the correct stLinkCriteria = command, ex: "[WorkOrderOriginator]=" & Me![UserName]
Of course you could get fancy and have each button just construct the stLinkCriteria and then pass it to a generalized routine... saving the replication of the rest of the code.
2010-05-05, 17:32 #3
- Join Date
- Jun 2002
- Mt Macedon, Victoria, Australia
- Thanked 45 Times in 44 Posts
The lines above that you use to open the form apply a filter. This acts like an extra criterion has been added (temporarily) to the form's query.
Opening forms with filters provides great flexibility, because you can base the form on a very general query that returns all records, then open it with a range of different filters, according to the needs of the situation.Regards