I have what I thought would be simple to do in Access.
Imagine I have the following tables (generated in SQL):
CREATE TABLE Projects (
ID int IDENTITY(1,1) PRIMARY KEY,
RequestStatus int FOREIGN KEY REFERENCES RequestStatus(ID),
mName varchar(50)
);
CREATE TABLE RequestStatus (
ID int IDENTITY(1,1) PRIMARY KEY,
RequestStatus varchar(50) unique
);
I want to create a form in Access on the Projects table which has a dropdown allowing users to change RequestStatus - but displaying the varchar(50) values.
For example, if RequestStatus.RequestStatus values are:
I want the drop down to show the options "one" and "two" but actually, when they are selected, update my Projects.RequestStatus to be 1 or 2, respectively.
I can very easily push the "one" and "two" values into the dropdown by simply making my Combobox:
But then, when I change the combo box value, it tries to insert a new value into the RequestStatus table - this is obviously a problem.
If I change the ControlSource however to be Projects.RequestStatus, it doesn't let me select using the "one" or "two" indicators as the value which is displayed is 1/2 etc.
How can I achieve this?
In the Choose Builder dialog box, click Combo Box Wizard, and then click OK. In the Combo Box Wizard dialog box, select the Find a record on my form based on the value I selected in my combo box option, and then click Next. Select the ProductID and ProductName fields, and then click Next. Click Finish.
In Design view, open a form that is based on a record source that includes the Lookup field. If the Field List pane isn't displayed, press Alt+F8 to display it. Double-click the Lookup field, or drag the Lookup field from the Field List pane to the form. Access automatically creates a combo box bound to the field.
Generally, a combo box is appropriate when there is a list of suggested choices, and a list box is appropriate when you want to limit input to what is on the list. A combo box contains a text box field, so choices not on the list can be typed in.
Try this for your combo box:
Control Source: Projects.RequestStatus
Row Source: SELECT ID, RequestStatus FROM RequestStatus
Bound Column: 1
Column Count: 2
Column Widths: 0";1"
That way your combo box has two columns (ID and RequestStatus), but the first column is hidden because its width is zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With