Generate Report in MS Access with Dynamic Layout - ms-access

I have a task to create ad-hoc report generator engine in MS Access where user can select table, fields and criteria, and report will be dynamically generated based on the given parameters.
I create Access form as the interface for user to input the required parameters (using ComboBox and ListBox to select table and field(s)). All tables are stored in Access database. I have successfuly bind list of tables and fields to the ComboBox and ListBox.
My questions is..
How do I generate dynamic report layout based on number of fields selected in the form? Let say if the user choose more fields, the field width will be smaller than if he choose less number of fields (I want the report fit Form/Report View).
FYI, I am working MS Access 2010.

There is a property called Can Grow just select the field you want to grow and change it to yes. Keep in mind however that the CanGrow property does not apply to a form or report page header and page footer sections.

Related

How to create MS Access Report With dynamic number of columns

I am building a report in MS Access based on a crosstab query. Therefore I do not know the number of columns or column headers in advance. I have created a template report with one column. In VBA I make a copy of this template report. Using the report recordsource, I then add labels to the report header and textboxes to the report detail and give the report headers the correct name. I set the label and textbox properties using the settings of the label and textbox from the template report. All this is done in VBA.
Is there a better way to create a report with dynamic number of columns? If not, using VBA, is it possible to add columns to the report grid and snap the labels and textboxes that were dynamically created to the grid.

Access 2016 drop-down list appearing in Reports and Queries

In Access 2016 I have a table called 'Orders'.
I also have a Form (also called 'Orders') that we use to enter order information. On the form, one field in particular ('Company') is a drop-down list. The control source is a second table called 'Companies'. And the Row Source is a SQL Query:
SELECT [Companies].[ID], [Companies].[CompanyName] FROM Companies ORDER BY [CompanyName];
So, when the user is entering an order into the Form, he/she can select the company name from this drop-down list and it in turn updates the Orders table. All basic stuff, and it works fine.
Next, I created a query (also called 'Orders') and it is based off of the Orders table.
When I run the query in Access and view it as a Datasheet, I was surprised to notice that the Company field (IN THE QUERY datasheet) is a drop-down list. Not only that, it even lets me change the value - right here in the query! If I view the SQL for this query, I can see that it is a SELECT query. In my mind, a SELECT query is read only. So my questions are - What's a drop-down list doing in a Query, and WHY does Access let me edit the values directly in the query? Isn't this supposed to be read only?
Next question:
After verifying that all of the data I need is in the Orders query, I then created a report (called 'All Orders') and the control source for this report is the Orders query. (not the table).
When I view the Report in Design view, there's the drop-down list again. Why? I am just looking to add the Company name that the user selected when they completed the form. I realize that the form Control for entering that data (on the FORM) is a drop-down list. But here I am building a report and I just want the VALUE to appear here. Not the drop down control? (I know that when I print the report or view it on the screen, the drop-down boxes go away and all I see is the actual text). But my question is - WHY is Access showing me a drop-down list control on a report? and in a select query? The query and the report are no place for editing data. I just want the value that was selected.
That's because you've defined the lookup list in the table. If you do so, it propagates to queries and new reports and forms, and will be the default way to view the data everywhere you've placed it.
Open your table in design view, and change the display control for your field back to text box. Note that any forms and reports will need to be edited or recreated, for queries the change should propagate.

choose multiple items from list box

Access 2007 How do I allow the user to pick multiple items from a dropdown or list box?
I can use either. Example, I add a list box to my form and make it bound to a field from the query the form was made from. Now the user needs to be able to pick 2-3 of the values in the list box.
I know that in the listbox properties (Multi Select) I can pick simple or Extended, but this does not save the choices.
Thanks
In the Access MDB database format, I don't believe it's possible to have a bound list box which is also multi-select. (Edit: Testing showed me it is possible to set the multi-select property ... but nothing gets stored in the bound field ... so it's not useful.) Which of multiple selected values should the db engine store?
Since you have Access 2007, you can use ACCDB format, and you might be able to have a multi-select list box if it's bound to a multi-value field. However, multi-value fields are too similar to lookup fields, and lookup fields are evil. (The Evils of Lookup Fields in Tables).
If it were me, I would choose a different approach for the user interface.

Combo-box data input in Datasheet View in 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.

Access 2007 not auto-updating calculation with bound fields

I developed an Access 2003 database with a form that has a number of bound input text fields. As the user update the value in these fields, the table is updated with the changed value. I also have an unbound textfield that displays a calculated value from the user input. This does not use the values from the textfields on the form, but directly from the table.
The Control Source of this textfield is something like:
=[field1]+[field2]+[field3]
Rather than
=txtInput1.value+txtInput2.value+txtInput3.value
In Access 2003, the calculated textfield get updated automatically as a user changes the bound input fields. However some of the users are using Access 2007 and they don't get the calculated field updated automatically, unless they reload the form.
It only updates automatically if I use the input textfields rather than the bound fields to perform the calculation.
I have selected "Allow this content" in the security warning. Is there anything else I can do to make it behave like in Access 2003?
Thanks