Is this even possible??

GregoryWest

Registered User.
Local time
Today, 15:37
Joined
Apr 13, 2014
Messages
161
I have a form, in two places it is called from VBA code and I would like to supply the required number that in the 3rd place the user has to enter. Can this be done?

What I mean is there is a button where the user can open a form, for editing. The user is required to enter the transaction number to edit.

In two other places in my program I have VBA code create a new transaction and then open the same form for editing. What I would like to happen is if the VBA code opens the form is there a way the VBA code can open the form AND supply the transaction number at the same time?
 
I can see how you are thinking of passing parameters, how do I then use these parameters in the select query to either get the user to enter the data, or use the data passed? My problem is not so much passing information, but trying to open the form with a query that asks the user for information, or one that uses information available.

:banghead:
 
Check when you press the button to open the form if you need to run the query or not.
You can check a control for a value using IsNull(Me.YourControl)
 
Minty interesting approach, in my query I have a field with a prompt [What transaction do you need?] This is run all the time, what I would like it to have the value filled in automatically if the form is opened from particular controls. What I am trying to avoid is having two copies of the same form with all its internal controls and switches.
 
I can see how you are thinking of passing parameters, how do I then use these parameters in the select query to either get the user to enter the data, or use the data passed? My problem is not so much passing information, but trying to open the form with a query that asks the user for information, or one that uses information available.

:banghead:
The OpenForm command also has a Where Condition argument to apply a filter to the next form's RecordSource.
http://www.baldyweb.com/wherecondition.htm
 
Rural guy, that looks good for the times the form is opened and the transaction number is known, how do I get my code to deal with the time the form is opened and the transaction number has to be prompted for?
 
Right now it is embedded in the query that the form uses, this can be changed if required.
 
Everything you want to accomplish can be achieved in the OnLoad event of the form.
 
I sort of get that, where I am hung up is how to I get the openform to prompt in one case, and in a different case prompt the user for input. I know this must be pretty easy, and I know I am going to kick myself when I see how. Right now I do not quite get how to do this :(
 
It is just using the Else part of the If Else End If that is in the link in post #2 differently. Just ask a question instead.
 
So are there any conditions on the calling form that could be used to determine if you want to run the query or not?
 
I'm starting to get the feeling you are not particularly comfortable using VBA code. Could that be true?
 
If you want us to write if for you, which we'll be glad to do, then we'll need to ask a few more questions as Minty has done.
 
You still working on it Greg or would you like a little more specific help?
 
Still working on it. I am still a little confused how to get a query to behave in two different ways. Or am I going about this all the wrong way?
 
You probably don't need to. Based on a set of conditions you do run the query. If not you fill your form out with the values on another form, and / or run a different query.
 
I'm not sure of all of your requirements but I tend to use generic queries for my forms and limit them with WhereConditions. What two ways are you referring to?
 
I think that is the problem I have the where conditions in the query itself:
SELECT PartsWorkOrder.*, PartsWorkOrder.Order_Number
FROM PartsWorkOrder
WHERE (((PartsWorkOrder.Order_Number)=[Enter Order Number]));

There are three buttons on a form, one of them the user presses and is prompted for the order number, then the form is opened.
The other two create a bunch of new records in three tables all through VBA then I would like to open the same form as before, but not have the user prompted for the Order Number as the calling VBA code already knows the number. The part I cant quite figure out is how to I get the VBA code to supply the prompt [Enter Order Number].

Does this make a little more sense? The problem with the form is there is a ton of controls behind various input fields, I am hoping hot to have two forms and the need to make changes twice (once on each form)
 

Users who are viewing this thread

Back
Top Bottom