Assigning a string value from parent form

gschimek

Registered User.
Local time
Today, 02:14
Joined
Oct 2, 2006
Messages
102
I'm trying to use ghudson's File Browsing form on a subform on my main form. The code is written to have a static file location to look for files. I want to make that dynamic based on the record that I'm viewing.

I thought about doing it via VBA, and taking the value of the Parent Form's FirstName and LastName fields and assigning them to strings. My problem is that I don't know how to do that.

So, in VBA, how do I assign the value of a text box from the parent form to a string variable in the subform? I don't think I can link master and child fields in the form because the data sources on the parent and child forms are not related in any way.
 
Hmm. I thought I tried that and it didn't work. I guess I must not have been doing it correctly before. But all is well now. Thanks. Now here's another wrinkle to the problem.

One of the variables I'm trying to set is CompanyName. In my form, I have a combo box that displays the company name. But it binds the value of the CompanyID. My row source is a 4 column query, and I've set the column widths of columns 1-3 to 0", so I only see column 4, the company name. But column 1, the company ID, is what is bound to the table.

So, when I go to assign the value of the combo box CompanyName to a string, it assigns 2 instead of XYZ Company. How do I tell it to take the value of the combo box (which is the companyID), look it up in the CompanyNames table and return the corresponding company name so that I can assign it to the variable?
 
whatever columns you see in your combo box are not important. The ACTUAL columns in the combo box are what is important, defined by the source query.

Normally a cbobox is bound to the first column, which is set to width 0, and other columns sized to suit. The columns of a cbobox are indexed, zero based, so column 1 is actual referenced as cbobox.columns(0). As already stated, this column is generally stored as the value of the combo box, so can normally be referred to just as cbobox. If your name column is the fourth column of the cbobox then it is cbobox.columns(3).
 
THANK YOU! That worked great. And I think it was one of the best responses to a question I've seen. You explained it perfectly.
 

Users who are viewing this thread

Back
Top Bottom