Can I bind 3 comboboxes to one form? - ms-access

Each of three columns: cust_id, cust_name, cust_company are in are in three combo boxes, each returning the cust_id as the key. When any of the combo boxes has a value chosen, I'd like to update a sub-form's data. I'm new to access, but my background is programming. I've yet to figure out where anything is beyond create wizards and property sheets, so be gentle.
Thanks!
Jimbus

Use three subforms:
Make the main form unbound
Place the three comboboxes to select cust_id on the main form
Place the tab control on the main form
Place a subform on each of the three pages of the tab control
On the main form, for each of the subforms, set these properties of the subform control that holds it:
LinkChildFields: The foreign key of the subform (cust_id)
LinkMasterFields: The combobox used to select cust_id for the subform
Zero code.

Related

Populate a ComboBox with the Result of a Text Box

I have a form in my Access database called:
formAcademyRegister
Inside this form I have a combo box called:
EmployeeCode
This combo box retrieves its data from a table called:
Employees
The primary key on this field is EmployeeID
To make it easier for the user I created a form called formsEmployeeSearch. In this form use some text fields to make it easier to search for the employee using a first name or last name, returing the values to a list box on this form. This list box has three fields:
EmployeeID
FirstName
LastName
All these fields are also populated using the Employees table so there won't be any data type issues.
Below the list box on the search form I have a button called
butUpdateEmployeeID
When the button is clicked, I want the following to happen:
The EmployeeCode combo box in the formAcademyRegister be updated with the employeeID as selected in the list in the formsEmployeeSearch form
The formsEmployeeSearch to be closed
I am comfortable with the process of closing the form, I am however struggling with the code to populate that combo box with the value selected in the list box.
I tried the following:
Me.Form!formAcademyRegister!EmployeeCode = Me!lstEmpSearchResult.Value
But this is not working.
Try the below.
Forms.formAcademyRegister.EmployeeCode.Value = lstEmpSearchResult.Value
DoCmd.Close acForm, Me.Name, acSavePrompt
A couple of notes.
The keyword Me is not required when the code is behind the form itself, but in some situations it makes the code more readable.
The .Value property is default property (where applicable) thus can be omitted. It's best practice to keep it for clarity.
Me.Form is reference to current Form (where code is).
Forms is collection. Assignement to collection item "Collection(ItemNameOrItemIndex)
Forms("formAcademyRegister").cmbEmployeeCode.Value = Me.lstEmpSearchResult

Getting CurrentRecord from a table in a subform

I have a company form that list their basic info with a subform tab that list more company info like contacts, parts and orders. I use a tab control where each tab has a table with basic info about each. I am trying to open another form that has detailed information about the user highlighted row in the table, but cannot figure out how to read which row is selected.
The form is call Customer, the tab form is called tabDetails, the parts tab is caled tabParts and the table that lists all the parts for the company is called tblPartsList.
This is what I thought would work.
ID = Me!tabDetails!tabParts!tblPartsList!CurrentRecord![ID]
The solution that I found to work was just to call the table control.
ID = tblPartsList![ID]
Thanks for everyone's help.
Use the Form property of the subform control.
tabDetails here is the name of the subform control:
ID = Me!tabDetails.Form![ID].Value
or:
ID = Me!tabDetails.Form!tblPartsList.[ID].Value
The form's tabs are only for ordering the controls. They are not containers for these.
You can use ActiveControl property to refer to the control that has the focus at runtime
ID= Screen.ActiveControl.Parent("ID")

In a form, how do I display field data from another table as text without a combobox?

tblStaff lists staff and tblAssign lists staff assignments. They are linked through StaffID, which is tblStaff's primary key and tblAssign's foreign key.
I have created formAssign based on tblAssign. In formAssign, StaffID is set through a combo box where the tblStaff's StaffName is displayed and selcted (created with combo box wizard). However, I also want to display some other fields in formAssign from tblStaff that would vary based on StaffID (eg. StaffPaygrade), but I don't want this data to display in a combo box. I want it just to appear as text.
The closest thing I can come up with is to make a combo box displaying StaffPaygrade linked through StaffID and then lock it, but this looks pretty bad.
Any help would be appreciated!

One combo box for two queries Access

I have a form that needs to use two combo boxes but the values in the second combo should come from two different tables based on the first combo selection. If I select option A in combo_1 I want to list all the agency names from tblRefAgency in combo_2. If I select option B in combo_1 I want to list all of the carriers from tblrefCarrier in combo_2. I can add VB code to hide/show two different combo boxes and then overlap them, but I feel I should be able to do this in a query. Thoughts?
As long as you are dealing with a single form, you can easily set the row source of the second combo in the After Update event of the first combo.
If Me.Combo1=1 Then
Me.combo2.RowSource = "SELECT ID, Description FROM tblRefAgency
End If
If the 2nd combo is bound to a field, you will also have to set the combo in the current event to ensure that data is displayed properly.

msacces 2010 how to create table with comboboxes in subtable from many related tables

I have the tables:
products, measures, colors
for each product I have related measures and colors.
Also I have a form with subtable where I need to show the table with columns:
[products] comboboxColumn, [measures] comboboxColumn and [colors] comboboxColumn.
The rows should be selected product, selected measure, selected color.
The question is:
how can I filter the measures ComboBox list for [measures] combobox-Cell (or colors ComboBox list) in my grid selected row, when I choosing a product from [products] combobox-Cell in that very selected row?
I suggest you use a continuous form rather than a datasheet. Create the combo and populate it with the relevant values in the current event and bind it to the correct field in your table. To avoid confusing the user, include a textbox bound to that field also. You can lock the textbox and label the combobox column something like "Choose Size". You can use conditional formatting to make the whole think prettier.