Combo-box data input in Datasheet View in MS Access - ms-access

I need help in creating my first application in MS Access 2007.
Consider a table in MS Access with a column "AgeGroup" and the possible values for this column are "Child" and "Adult". Is there an option in MS Access to enter data into this column using a combo-box with these two values in Datasheet view?

The Simple (but questionable) solution:
(in strict accordance with OP's question)
Create a new table
Add the column which you want to control by a combobox and give it a column name and the Text type.
Make sure that the appropriate column is selected and then click the Lookup tab page in the MS Access table designer
Change the Display Control from TextBox to Combo Box
Select Row Source Type = Value List
Enter the following for Row Source: Child,Adult
Since you probably want to leverage the fact that MS Access is a relational database, you could also have the have the Child and Adult alternatives as rows in a separate AgeCategory table. In order to connect the rows in this table with your combo box you would have to use other Lookup settings. This I leave as an excercise to you.
EDIT: As HansUp is pointing out, it is really not a very good solution define this combo box lookup along with the table definition.
This is probably a better approach for a real world solution:
Create your table
Create a new form which uses your table as data source
Add a combo-box to the form and specify the row sourcing for it
Switch the Form to Datasheet View. A form in Datasheet View looks exactly like the type of row editor which you get when you double-click on a table.

Read The Evils of Lookup Fields in Tables
Instead of creating an evil lookup field in your table, build a form which uses the table (or a query based on the table) as the form's record source.
Add your combo box to the form. Use a value list or another query as the combo's row source. Switch the form to datasheet view. You can also select datasheet for "Default View" on the form's property sheet.

Related

Lookup tables in forms not displaying correctly in tables

So, I had lookup fields on my tables. I have recently learned that this is a bad idea. So, I'm trying to convert them to lookup fields in the forms that fill those tables.
The lookup list is drawn from another table with the individual values. On the table, I went into design view under the lookup tag and changed "combo box" to "text box." The fields that were previously lookup fields now display the "key" of the item that was displayed previously in the field.
The form still shows the correct lookup value but the associated table no longer does it instead shows the number associated with the value and not the value. What do I need to do to fix this.
I guess my question boils down to not knowing how to link a lookup field in a form to a text field in a table.
You don't need to change your forms, just update your tables - change lookup from combobox to text box, you did this correctly.
Existing forms should work as usual, with comboboxes, settings for those comboboxes were copied from table settings and not liked to table settings anymore.
In new forms you'll need to do the same manually: after placing the field to the form convert it to combobox then setup correct Row Source, Column Count and Column Widths properties of combobox.

Ms Access Datasheet view - only one column editable

There is access datasheet sub-form and users should only be able to edit count column. How can that be done ?
Currently, If I change the form property Allow Edits = True, users can update any cell.
Also, the user should be able to enter different count values. If a user types 1 in first cell, it get copied for all the rows.
How can this be achieved?
For each control on the form that you don't want editable, set the Enabled property to False (or the Locked property).
For the count copying to all rows, we need to see the query that this datasheet is based on to answer that. If the count is an unbound textbox, you will get the behavior you are seeing as Access will only create a single instance of the control, then repaint that single instance across all rows (note that this is the same with continuous forms as well)
Instead, create a query that has this field (or a dummy table) and bind to that, making sure to bind the textbox to the dummy field, and then you should be able to edit the value on a per-row basis.

How to cause Subdatasheet to display with Form's Datasheet view

In my database is a Form based on a query which has a subdatasheet defined. When the Form is in DataSheet view, each record shows the plus sign which can be expanded to show related records according the subdatasheet defined on the source query. In other words, the Datasheet view automatically shows the Subdatasheet--as expected and as desired, so I know it can function like this.
I then created a new Form based on the same query as the existing, working Form. However, the new Datasheet view will not show the Subdatasheet... no plus sign, nothing. Next I created a test database with a couple related tables, and I also ensured that the tables have a Subdatasheet defined. If I open the tables directly I see the plus signs and Subdatasheet as expected. But once again if I define a form on those tables, it will not show the Subdatasheet when viewed in Datasheet mode. There is no separate setting for an Access Form to define the Subdatasheet, rather it can only inherit the Subdatasheet setting from its record source object (i.e. table or query).
Is there any way to force a Form (in Datasheet view) to show the Subdatasheet already defined on the record source object? Why might the new form function differently than the original even when it's based on the same query?
I'm using Access 2013 and database with 2007-2013 file format.
Subdatasheet view is only available in DataSheet view.
Also it is recommended to use Subdatasheet view for only reading and not editing as unexpected errors may result.
From Microsoft:
If you add subdatasheets to your tables, limit the use of these
subdatasheets to viewing, and not editing, important business data. If
you want to edit data in a table, we recommend that you use forms to
edit the data instead of subdatasheets, as data entry errors are more
likely to occur in datasheet view if users are not careful to scroll
to the correct cell. Also note that adding a subdatasheet to a large
table can adversely affect the performance of the table.
Microsoft Office Access automatically creates a subdatasheet when you
create a table that matches one of the following criteria:
The table is in a one-to-one relationship.
The table is the "one" side of a one-to-many relationship, where the
table's SubdatasheetName property is set to Auto.
A relationship is defined by matching the primary key and the foreign
key fields in the related tables.
You can also add a subdatasheet to any table, query, or form in a
database. In Datasheet view, a form can display only one subdatasheet
at a time.

microsoft access control source from a table in another group in a report

I am new to Microsoft access, and I am trying to make a report from the data in 2 tables. I am using text boxes and setting the control source to the value from the table in the property sheet. All but one works fine, the one from the other table. The the value pops up with a "Enter Parameter Value" then the name of the main table when I switch to report view. The control source for the text box is "=[Main table]![Due date]" I made it with the little Expression maker in Expression builder. What am I doing wrong?
I found something close but it did not help me fix it link.
A form/report can only have one Record Source. Create a query that combines the two into a single query, and then use that as the form/report's Record Source.
If you are creating a form and you want the underlying table to be editable, join the tables together and make sure each of them has a primary key.

How can I create a Multiple Value Combo box on an Unbound Form

I need your help on MS Access 2007.
I have a big problem with my MS Access Unbound Form.
How can I create a combo box i do not want bound to a table, show a multiple value List?
The Combo is named Sector and want these values to be selected in Multiples 9Which should be possible in Access 2007) from the Drop Down List: Fertilizer, Seeds, Pesticides, Veterinary products, Animal Feed, General.
Which Select Statement or VBA code can I use. I need a solution to handle this please.
Precisely a ListBox control will help you. Since you are using it in MS Access - it makes it much easier with the wizard where you can type the items list. Or if you want to use VBA, then you can load the list using AddItem property of ListBox control in the Form_Load event.
Here is one way of doing what you want:
Open up the table your Form will use. Then: Datasheet view, Datasheet Tab, Lookup Column. Select option: I will type in ... Next Under Col1 enter one of the user choices you want; for example
A Dogs, then under that enter another choice; for example B Cats, etc Next give your lookup column label a name or stay with the default. Finally, Check Allow Multiple Values box. Finish.
You now have a table with a combo box that allows the user to select 0, 1 or many choices.
But you want it on a Form.
Create Tab, Click Form. You now have a Form that has a multi value combobox.
But you want it on a form you already created.
Right click the ComboBox. Copy. Close the table and open the form you want the ComboBox to be a part of.
Right click on a clean part of the form and Paste.
Hope this is what you were looking for.