I am attempting to set the value of a combo box from a "Splash Screen" type form in Access that will take the user's computer name and load two combo boxes on another form with the Employee ID and Manager ID, which are both bound columns of the combo boxes, which are unbound themselves. I can get the IDs in the combo box, but i want it to still display column 2 (Names) of both combo boxes. Right now it just displays the IDs. Anyone got any ideas how i can get it to react like i actually picked it in the combo box?
So, comboboxes can sometimes be tricky, but once you get it down you should be good to go.
So, when looking at a Combobox's properties,
The Format tab :
ColumnCount: 2 <-- You want the ID and the Name
ColumnWidths: 0";1" <--- You're hiding the ID field, which is the first column
The data tab:
This is where you're going to tell Access what data you're supplying for your combobox.
Usually it's a query or table data source. If it's a query you should be selecting the ID and Name fields, and use that query in the RowSource property in the Data tab.
Row Source: Select ID, Name FROM YourTable
Row Source Type: Table/Query
When you use the Wizard to create the combobox, it's fairly straightforward. When Access asks you to format your data source, you completely shrink the ID column, so it hides it (but it's still there).
The steps would be:
I want the combobox to look up the values in a table or query
Select the Table or Query
Select the Fields (ID and Name seem appropriate for your scenario)
Any sorting you may want
The next screen is where we want to hide our ID column, so shrink it entirely
The next screen is where we tell Access that we want the ID to be in scope (selected) when we select a combobox item
Name it & be proud
Related
Challenge: I've created a simple repository in MSACCESS (#1) that displays one or more owners of a corporate server.
The sub-form "asset-owners" is linked to the corp-assets main-form (#2). I've added a pulldown whereby the user can select a name (#3) from the address_book (#4) table and prepopulate the owners sub-form.
Objective: I would like to auto populate the associated "Occupation", "Favorite Food", and "Favorite Movie" fields when the user selects a name from the pulldown (#5).
I am not exactly sure how I should configure the occupation food and movie fields to auto-populate with such data AFTER the user has selected the name. I was thinking an inline query for each field, but I suspect it may be simpler than that.
Note: occupation, food, and movie data comes from the address_book (#4).
Many thanks!
I hope you don't want to repeat data in another table. If you just want to display the related data, options:
create multi-column combobox then expression in textbox references combobox column by index - index begins with 0 =[comboboxname].Column(1)
include lookup table in form RecordSource and bind textboxes to fields - set them Locked Yes and TabStop No
DLookup() expression in textbox.
I have a table with a combination of Text Boxes and Comboboxes all bound to fields in a Users table.
The combo boxes are used to select items such as Location, Access rights and Title which are all listed in seperate tables.
However as the values for Location, Access rights and Title are stored in my users table as the integer Primary keys from the related tables this is what is being displayed on my form.
How do I set the combobox field to display the Loc_Name rather than the Loc_ID but still be bound to the original users table?
The second problem I have is that when I select the dropdown for the combo box I get the List of Locations (for example) which is fine and when I select the valid location it displays the Loc_Name in the combobox field. The problem here is that because the combobox is bound to an integer type field in the Users table the form will not accept the String Loc_Name only an integer value.
Am I going about this the wrong way????
Details of settings:
The Location combobox on my form is bound to the Location field in my users table which stores the foreign key integer value from the locations table.
The ComboBox datasource is set to the Locations Table Binding SOurce
The Combobox Display member is set to Loc_Name
The Combobox Value Member is set to Loc_ID
The Selected value is set to (None)
Sorry. Should have put this here.
Looks like I might have been going about it the wrong way. Instead of referencing the valueID with the combo box I had to create a SELECT that join the two data tables and display the Joined data. On update the combobox had to be set to reference the original ID Field. Seeming like a very roundabout way of doing it. No where near as neat as Access.
I'm using Access. I'm programming in vba.
When I first load my form a combobox displays content from the wrong column. If I go into design view and come back to form view, the combobox then displays content from the correct column. I have looked at the format strings, but they specify the correct column. I've tried to bind the correct column. I've tried to requery the combobox.
In the application a procedure references a service and a task. We have a table where a service was requested for a particular patient. A patient can request up to three distinct services. Those services each have a task associated with them. The user selects a patient. The patient has an associated patient request id. This id is used in a query to select the requested services. The user then selects a procedure or a service and task to select a unique row in the table.
The combobox for selecting the procedure is the one having problem.
When a procedure is selected, 1) the appropriate ids for the service and task table are saved in a text field, 2) the appropriate columns in the service and task comboboxes are bound, then 3) the ids in the text fields are assigned as the indexes of the service and task comboboxes.
When a service and subsequent task are selected, the procedure id is saved to a text box, the appropriate column is bound, and the index is assigned to the procedure code combobox. All of that works fine.
I do end up leaving the columns bound. I tried to set them to zero after processing, but that messed up things. binding is about assigning indexes. The Format string should be controlling the content displayed in a given combobox.
How can I force the first combobox to display what it is supposed to display without cycling views?
I've tried to cycle view pro grammatically, but it generates errors when you try to do it with me.
After additional testing, I believe that the column binding is causing the problem. Weird things have happened due to column bindings. I had set them to 0 to eliminate those problems, but the id assignment has me binding the comboboxes again.
David Locke
I am writing a query based on a Table which is populated via a Form with several combo boxes. The information is stored in the Table as the Primary Key of the Combobox value which I understand to be correct. However, when I run a query or report based on the Table, I would like to display the Combo box Value rather than the Primary Key ID. Is there a way to do this other than using a Lookup to the combobox in the Table?
Thanks in advance for your help.
JB
It depends on how you have your combo boxes set up. Are they populated from a list in the field or from another table?
If from a list you entered in the table field where the value is stored, you should just store the value.
If they are from a separate table, then set the relationship from the combo lookup table's primary key/ID to a field in the main table that stores the combo selection which should be a number type. In a query, add both your main table and the other table where values for the combo are stored and add the value to your results from the combo value table along with the data from your main table.
It's a little confusing to say you want to query a combobox value, essentially you need to look at the SQL source of the combobox first in order to see where it draws it's values from. You then need to link this back to your query that you are running, as long as there is a common PK/FK between these then you can just perform an INNER JOIN on that.
I have an application in Access 2003 that I am working on. In it, I have an employee table, which is connected to two other tables. The two connected tables are tables that hold a few fixed KeyWords. In my main employee table, I just have the ID from the other table, rather than having the whole word.
I wanted to make a form for entering data into these tables, so I made a query from the three tables that shows the all the regular fields of the employee table except instead of those two ID's, I showed the words themselves.
I then made the form and set the query as the RecordSource. The fields that have keywords are Combo boxes on my form, and their ControlSource is the keyword field from the query (like I mentioned earlier, the value can only be one keyword out of a list). Now, the problem I face is this: When I want to see a single record, it shows the correct value in the ComboBox, but when dropdown the menu, it doesnt show any of the other values.
What is the best way to do this? Am I doing this in the wrong way?
Thank you
I'd approach this slightly differently, set the combo box Row Sources to include both the id and text fields (you can hide the ID column if required by setting it's width to zero). Now add the ID fields to the employee query; you shouldn't need to join the other tables to the Employee table in this query, these fields are foreign keys and the combo boxes should show the text for you automatically. Set the form Record Source to this query, now set the combo box Control Source to the appropriate ID value from the form Record Source.
If you let the wizard build a form for you based on the Employee table you will see this approach in action.
ControlSource is the column name of the table where any user entry will be saved.
RowSource is where you type the name of the saved query or manual query typed directly into that field, which is used to provide a list of available drop down options for the combo box.
RowSourceType should be set to Table/Query, which is based on aforementioned RowSource method.
Now to correct the problem of only displaying what you begin to type (i.e. "Allow AutoCorrect" in Property Sheet > Other) or already have saved for that record without other options appearing after clicking the drop down is the following:
In Design View, click the combobox in question.
Property Sheet > Format > Column Count = set the desired number of columns to display in drop down.
Property Sheet > Format > Column Widths = set the desired width of column in the drop down.
Property Sheet > Format > List Width = set the desired width of the drop down itself.
Property Sheet > Data > Bound Column = set to the column of query table (i.e. 1 for ID and 2 for list options, if you only have two entries)
Note: If your desired drop down options are column two and not column one (makes things easier btw) then do the following change from above:
Property Sheet > Format > Column Count = set the desired number of columns to two.
Property Sheet > Format > Column Widths = add two entries 0",1" which means the ID field is not visible (0") and the options field is one-inch.
The easiest way to sort this out in the beginning is to view the column header names to know what you are looking at in the meantime by doing the following:
Property Sheet > Format > Column Heads = set to yes. At least you will know what is showing and whether or not you are on the right track.
I had this same issue in access 2016 and the issue was with my datatype. The combo box didnt accept 'Longtext' so i just changed datatype to 'shorttext' instead and all the values appeared.
You have set the query as the recordsource for the form. A form only shows (and ties to) ONE record at a time.
Since you want the combo box to show all the values, you should set the RecordSource of the ComboBox to your query.