load new set of data into subform dynamically? (1 Viewer)

TechGuy

New member
Local time
Today, 07:59
Joined
Apr 21, 2020
Messages
9
Hi there,

I have a main form with one subform. they are linked together by Employee_Number fields on both forms(LinkMasterField and ChildMasterField). I would like to be able to change the subform's data for another employee number -while I am on that same main form . What is the best way to this? I have tried using control (textbox1) as the linkMasterfield . This textbox1 is assigned to Employee_number field of the main form. Then I have a combobox for user to pick different employee. When they select an employee from the combobox, I tried to assign the textbox1 to the selected employee and hoping that the subform would load new data based on that textbox1. But it has error of cannot assign value to the Textbox1. I wonder if it is being assigned to an employee_number right now.

Thanks in advance of your help.

Andy
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:59
Joined
Oct 29, 2018
Messages
21,473
Hi Andy. Are you trying to view another employee's data in the subform without changing the employee data in the main form?
 

TechGuy

New member
Local time
Today, 07:59
Joined
Apr 21, 2020
Messages
9
Hi DBguy,
Thanks for your quick response.
I've figured it out now. I assigned the TExtbox1 to the Employee_number when the form loads up (employee number is passed from main menu form). Then when I select the employee from the combobox , it will change the textbox1 value. this way, I get to keep the main employee information on the main form as well. However, as an option, I want to know how you can change the main form and sub form employee's info (sync the change), when I made selection on combobox (not critical, but want to know if it can be done).

Cheers,
Andy
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:59
Joined
Feb 28, 2001
Messages
27,186
Make a dummy form. Create a combo box on it with wizards enabled. One of the wizard's options is to make the combo "navigate" to a particular record for you. Do that and see what the code looks like. Then use similar code on your main form. Because the main is linked to the subform, they should navigate together.
 

TechGuy

New member
Local time
Today, 07:59
Joined
Apr 21, 2020
Messages
9
Make a dummy form. Create a combo box on it with wizards enabled. One of the wizard's options is to make the combo "navigate" to a particular record for you. Do that and see what the code looks like. Then use similar code on your main form. Because the main is linked to the subform, they should navigate together.
Thanks Doc. That works like a charm.
Cheers,
Andy
 

Cronk

Registered User.
Local time
Today, 23:59
Joined
Jul 4, 2013
Messages
2,772
It seems dangerous to me to display another employees details in the sub form. I'd open the subform as a form with the second employee's information with the title of the form showing the second employee's name so there is no confusion.
 

TechGuy

New member
Local time
Today, 07:59
Joined
Apr 21, 2020
Messages
9
It seems dangerous to me to display another employees details in the sub form. I'd open the subform as a form with the second employee's information with the title of the form showing the second employee's name so there is no confusion.
Cronk,
Thanks for your input. In the subform, I am displaying a datasheet with the rows of the days that they work. If I want to put the employee's name on the subform (Datasheet), I have to figure out a way to display the employee's name only once in the 'datasheet'

Cheers,
Andy
 

Cronk

Registered User.
Local time
Today, 23:59
Joined
Jul 4, 2013
Messages
2,772
If you have a sub form linked on the EmployeeID and then you want to show the data for a second employee as selected using a combo, you would have to remove the link, and then filter the subform on the employeeID selected in the combo. If you want to display the name of the second employee in the sub form, the use a continuous form with header rather than a data form in the subform. I'd still recommend using a second instance of the form for displaying other data.
 

TechGuy

New member
Local time
Today, 07:59
Joined
Apr 21, 2020
Messages
9
Cronk,
Thanks for your suggestions, I will try that out. But my project is being on hold now since the company is not making money due the COVID19 pandemic. Plus it is oil/gas industry where oil price is hurting them.

Cheers,
Andy
 

Users who are viewing this thread

Top Bottom