Values not showing in Access form combo box - database

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.

Related

Problem with Showing Query Results on a Form

I'm having a Projects lists Continuous form where the form's Record Source is based upon a table.
I have a requirement to display a field from another table which is linked back to original table using its primary key. The primary key is a AutoNumber field, but when displaying in the form I've used Input mask something like this "TMG/FEA/"0000.
So I made:
a unbound list box
and made the Row source as the query which displays the relevant information from second table
This query was created using primary key displayed in form (I mean the [Forms]![Form Name].[Field] ) as the where clause.
But the results returns blank. I'm Stuck here. I'm not sure if the query is not working due to the Input Mask or because of something else. Please help me. Thanks in advance
You should add to form field listbox, and set following values:
Data: primary key of your first table
After this, that field will duplicate ID value. Now you should transform RecordSource of this field in order to see contents from second table. So you should set:
SELECT [PrimaryForeignKeyID], [DetailedField] FROM tblSecond;. Actually I don't know the contents of your second table. Whereas PrimaryForeignKeyID is a field that links second table to first, so-called FK.
After this set following properties of list box:
ColumnCount = 2
ColumnWidth = 0;2
AllowEdits = False
Save form and open it for viewing.
In this case, your listbox will show the associated contents of second table on form.
So to my mind it is better for you to do such simple tables and forms, and you'll realize idea.

Combobox showing Foreign Key not Reference Value

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.

hide ssrs textbox based on table data

I can hide a table with no data by using this function in the visibility expression - =Iif(CountRows() > 0, false, true)
But I have a textbox used as a heading for the table.
How do I hide the textbox if the table relating to it has no data?
Thanks
=iif(countRows("DataSet2") > 0, false, true)
Where DataSet2 is the name of your dataset. This is because you are now informing the expression to Count the Rows in DataSet2. As no rows exist, it is set to hidden.
Further information...
Is the heading for the table adjacent to the table? Are you aware you can add rows above a table to provide extra heading information?
For example you can Right Click the Row Header, Select Insert Row -> Above and a new Row appears. You can then merge the cells horizontally, and set a title for the table (for example)
Now when you set the table to be hidden, this header row is also hidden automatically.
I'm not sure this is applicable to your situation, but I thought it might be useful to add, to reduce the complexity of your report, if you were unaware of the possibility

Set combo box value using VBA

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

Access 2007 - Query displays Combobox Primary ID rather than Value

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.

Resources