Hi, Paul.
I have a form with the field "Control_Number". I want to store the value
contained in that field as a variable for use as a criteria in a select query.
You can do this by creating an actual query or by writing it entirely in VBA
code. I'll assume you want the easiest and quickest, but please advise if
you want to do this entirely in VBA code.
When you build the query, type the following in the "Criteria:" cell below
the "Control_Number" field in the QBE grid:
[Forms]![MyForm]![txtControl_Number]
Replace "MyForm" with the name of your open form and txtControl_Number with
the name of the text box displaying the value of the "Control_Number" field.
Save the query and then open it in Datasheet View (your form must be open and
have a value for this to work). Every time you run this query, it will use
the criteria supplied on this open form, no matter which record is displayed.
BTW, I'm not a VB programmer yet, so all my actions are
contained in Macros.
You can start by converting your macros to VBA and examining the code
produced by the Wizard and comparing that with the actions in the macro to
see what the equivalents are. To convert a macro, select the name of the
macro in the Database Window then select the Tools -> Macro -> Convert Macros
to Visual Basic to open the Convert Macros dialog window. Select the
"Convert" button and the macro will be converted for you and saved in a new
module named "Converted Macro- " followed by the name of your macro. Compile
the code.
Now you can use this public function in code or in property settings
whenever needed and just delete the original macro. Do this for all of your
macros when you feel you are ready to take the next step in the learning
process, and the next step in building more reliable, more flexible, and more
complex database applications.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
paulpenta said:
I have a form with the field "Control_Number". I want to store the value
contained in that field as a variable for use as a criteria in a select query.
How do I do that? BTW, I'm not a VB programmer yet, so all my actions are
contained in Macros.
Thanks