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

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!

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

Can I bind 3 comboboxes to one form?

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.

MS Access: Why is my combo box displaying the wrong value?

I have 2 columns that populate my combo box. They come from a table where I manually wrote in an ID and a clean_value field.
The goal:
Display both columns on a combo box on a form. The ID values should be on the left of the clean_value values when looking at the drop down list. When selecting something in the list, the combo box should display the clean_value, not the ID. When saving the form, the form should write the ID value to a different table.
What I've tried:
I set up the table to get the values from. I set up the combo box to show the 2 values in the correct orientation. The ID value is the value that is being written to the table.
The problem: When the user selects one of the values in the list, their selection shows the ID. I want to display the clean_value upon selection instead. How do I do this?
I found a way to do this. I grabbed the clean_value field, the ID field, then the clean_value field again in the row source, then I just set the width of the first clean_value field to 0.021".

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.