Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing/Sharing Values between forms

Status
Not open for further replies.

metrodub

Technical User
Dec 29, 2004
82
US
On one of my forms I have a command button that opens a pop-up form. When the pop-up form opens, I am able to share a few values from the previous form (the form not in focus) in text boxes through the On Load event trigger.

I have a combobox on the pop-up form that has two values (Flat Fee and Hourly Rate). I tried coding the After Update event so that if Flat Fee is chosen the Fee textbox is populated with the fourth column in a combobox from the out of focus form.

Code:
if Me!cboFeeType.Value = "Flat Fee" Then
         Me!txtFee = Forms!frmClass!cboInstructor.Column(3)

This does not work. Is there a way to make it work? Trigger from a different event?

Thanks in advance.

 
As I understand it, you can only access the 'Bound column' from the combo box - use that in a Lookup or query to populate your txtFee field.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
It should work. do you have four columns in your cboInstructor?

also, you might need to requery in order to 'see' it? to test, do this:

if Me!cboFeeType.Value = "Flat Fee" Then
Me!txtFee = "BLAH"

and see if BLAH or some other test item is visible in the txtFee box after you pick "Flat Fee."

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I tried the "test" and the textbox is not populated. Why do you suppose that is?
 
what's the rowsource sql for your Forms!frmClass!cboInstructor?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Sorry for the delayed response. Here is the SQL code:

SELECT [Instructors].[InstructorID], [Instructors].[VendorName], [Instructors].[BusinessName], [Instructors].[InstructorRate] FROM [Instructors] WHERE [Instructors].[InstructorRate] Is Not Null ORDER BY [VendorName];

I've used similar code to fill unbound text boxes on the Class form using this combobox so I'm not sure why it won't populate the pop-up form.
 
just more troubleshooting....

in afterupdate put

msgbox Forms!frmClass!cboInstructor.Column(3)

and see what you get.





Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I take that back. It doesn't work when it's in an If Statement, but DOES work when it's universal (ie, either choice is chosen).
 
Yikes...

Ignore the last post and go to the one before it. It DOES work.

Long day, sorry.
 
hmmm...more testing...

how about

me.txtFee

(dot instead of !)

are you sure of your text box name? is it a bound text box? are the types correct (i.e. both are numbers or both are text?)


Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Got it to work. Not sure what the reason was for not working prior, but it's working now. Thanks for your help.

Another question that ties to this situation. The data that is populated in the pop-up form (Development form) is stored in the Development table. How can I create a relationship between the Development table and the Class table (where the data from the lost focus form is stored)? If I have a DevID as a foreign key in the Class table, how can I associate the correct DevID with the ClassID? Does that make sense?
 
you say
If I have a DevID as a foreign key in the Class table, how can I associate the correct DevID with the ClassID?
Just the fact that you have the DevID as a foreign key in the Class table makes the two associated. Not sure what you are asking, sorry.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Sorry about the vagueness. Let me see if this example will shine a light on what I was trying to say.

Say I start filling in the fields in the Class Form and need to enter development data. I press the command button to open the Development Form. The form opens, populates with some data from the Class Form, etc, etc. I fill in some other fields, hence creating an autonumbered number (the DevID (primary key for the development table) lets say 1). When I close the Development Form, how can I make sure that the DevID in the Class table will be 1 (the DevID for the recordset that I just added)?
 
How about using the Development stuff in a subform instead? or the Class stuff in a subform on a Development main form? Then it's all automatic. Are you familiar with subforms? It will do just what you are looking for!

So how is your stuff structured? Are there many classes for a 'development'? Post your tables' structures and maybe we can find a good solution for you!

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top