On Aug 25, 10:27*pm, DeZZar <derrick.goost...@gmail.comwrote:
Quote:
Wayne,
>
Thank you so much for your help! *Such a simple solution has opened up
a world of functionality!!
>
Much appreciated!!
Dezzar,
I use the method above a lot if your query is going to be hardcoded
and not reused.
But, sometimes you want that window to be opened by 2 different
forms. If that's the case, then hard coding a pointer in the query to
the form won't work.
Here's some other methods to consider for your toolbox.
1. Limiting records in your window.
Another fairly easy way is to trigger a filter based on the "after
update" of a text box, list box, or combo box. You use the me.filter
and me.filteron commands to set a filter and apply it. Check the help
files on these. (You'd think the filter and filteron methods would be
used when you create a wizard combo box with "Find a record on my form
based on the value I selected in my combo box". But, that just
creates a "FindFirst" in the AfterUpdate event.)
Basically, if you wanted to narrow the records on a results screen,
first create an unbound combo called "cmbRecordIDChooser" in your form
header with "RecordID" as the bound column. Then, you could enter
afterupdate code that looks like this:
dim strFilter as string
strFilter = "[RecordID] = " & me.cmbRecordIDChooser
me.Filter = strFilter
me.FilterOn = True
2. Use the "criteria" method to open a form/report.
The "Open" event for forms and reports contains an option called
"criteria". You can set the criteria just like strFilter is set above
when you run the Open command. (This code is used by the button
wizard when you make a button with the "Open the form and find
specific data to display" option.)
The button Wizard will create code in this format.
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmRecordDisplay"
stLinkCriteria = "[RecordID]=" & Me![cmbRecordIDChooser]
DoCmd.OpenForm stDocName, , , stLinkCriteria
3. Combine the 2 concepts.
Now, here's the trick. Why set something and then have a button to
click a separate time? There's NO reason you can't just use this code
in your combo box's after update event. Just cut and paste the Wizard
Code from the button into the Wizard Code for the dropdown. And,
boom.... Someone picks something in the combo box, and immediately,
your window pops up.
You can use these kind of methods in lots of "After Update" senarios -
text boxes, list boxes, etc.
In fact, I think it's one of the earliest ways I started using VBA
code.
Best of luck,
Jon