I have a query based on two tables. The query is the RecordSource for several forms.
I can easily display fields from the query (such as CompanyID) in text boxes on a form, but I'd also like to display some of those that I left behind on the tables (such as CompanyName).
The simple answer would be to add all those fields from the tables to the query, but many of those fields are used only on one of the forms. I'd hate to clutter the query with lots of such fields if I can just pull "CompanyName" from the underlying table.
I hope there's another way to do it (linking the tables or something. I've seen an SQL query used as a RecordSource, but I don't know if that applies to me).
Normally a form is used for data entry/edit to only 1 table. Including other tables (such as lookup tables) in form RecordSource is usually not necessary and often just adds confusion.
Use a multi-column combobox to view associated data. For example, a combobox to select company can be designed to display CompanyName but save CompanyID into an Orders record.
RowSource: SELECT CompanyID, CompanyName, CompanyAddress FROM Companies ORDER BY CompanyName;
ColumnCount: 3
ColumnWidths: 0;1;0
BoundColumn: 1
ControlSource: field to save CompanyID into
Then the combobox will display company name.
Can also have a textbox display company address with expression that references combobox: =[cbxCompany].Column(2)
An alternative is DLookup() domain aggregate function expression in textbox but domain aggregate functions can cause slow performance in queries and on forms.
Yes, SQL statements can be used in RecordSource instead of referencing table or query object. Either way, if lookup tables are included, textboxes bound to those fields should be set as Locked Yes and TabStop No to prevent edit of those fields.
Related
I would like to build a tabular form that has editable fields, but also shows aggregated values of the children, e.g. a form "purchase order" that shows the sum of all items contained in the purchase order.
I could make an aggregate query and join it to the record source query of my main form, but that would make all fields of the query read-only.
I could create unbound fields and populate them with DLookUps, which would work but seems to create a lot of overhead, and is sluggish in datasheet view and tabular forms.
I could create a combo-box for my ID field, set the row source to my aggregate query an reference these columns in other fields of my form (Controlsource = [cboID].[Column](2) etc.). Maybe less overhead than solution 2, but also sluggish.
Populating fields through code will (I think) lead to all lines in datasheet view having the same value, that changes everytime you select a new record.
I can't believe there is no more graceful solution to this.
I've coded my entire database to rely on recordsets and updating those recordsets on click of record IDs within other forms. Then I discovered that I can't edit the records from the datasheet. So I need an alternative.
My database consists of the following tables: Customer, Address, Order, Details, Contact and Misc. Each of these tables has a PK which is stored in a table called Master_Bridge which constructs a unique combination of all the PKs.
I have a form which includes each of these tables as a subform. The user begins at the Customer subform. When they click the Customer_ID, the Address table needs to filter based on where that Customer_ID exists within the Master_Bridge.
I was hoping to store each of the IDs into a recordset, or an array of some type, and translate each of those values into the filter. Admittedly, my VBA isn't good enough that I know how to do that.
I also tried a nested select in the recordsource of the Customer form, where I selected all of the Address_IDs. Again, couldn't edit.
Do you folks have any suggestions on how to proceed with this? I'll also need the click of Address_ID to filter the Order form by using both the Customer_ID and the Address_ID. The rest of the tables/forms will utilize the above 3 IDs.
Pretty sure my issue is due to multivalued combo box fields-
I don't get duplicates in my query, but I do get duplicates in the report based on that query. It appears the duplicates are for records that have more than one value selected in one or more multivalued fields.
I've checked and the query is not using .Value fields. As far as I can tell the query is fine- it's the report that's creating duplicates.
Table design:
Table design
Multivalued fields are lookup fields that lookup values from a table:
Resource Categories
Provider type
Type/Format of Resource or Service
Target users
Accessibility
These fields are lookups with single choice combo box:
Local or National
I am a newbie to MS Access and trying make a productivity tracking program for where I work.
I have a main form that's bound to multiple subforms with ID and I need to add one more subform.
That subform is going to fetch all data from Personnel table in continuous form view, and I would like to add one checkbox and two more fields to each row in continuous form. The ticked rows needs to be stored in a different table.
Is there a way to do this?
You'll have to make the new table
Then make a query which relates the new table to the old and returns all of the values you want edited or displayed in your subform.
Make the subform based on this new query, since it is only 2 tables it should be editable if the join isn't to complicated.
Then using the Locked and Enabled Properties of the controls on your subform you can change what is editable and what isn't.
I will say that if this is a one to one relation between the new table and the eixisting table it would be much easier to just add the fields and deal with security/data reporting concerns elsewhere.
Attempt to clarify more
I am assuming your Personnel Table has a foreign key to the main table ID and a personnelID of its own. To have more fields that correspond to records in the Personnel table you need to create another table, we will call it CheckBoxes. Checkboxes needs to have a foreign key to the personnelID and then whatever fields and check boxes you require.
Then you need to make a Query that pulls from Personnel and CheckBoxes and joins them on the foreign key you have relating the two tables. Then make your continuous subform based on the query rather than a table.
Access makes the query creation really easy and this relaition should be simple enough to be able to edit through the query.
Again I would consider adding these fields to the personnel table rather than making your database more confusing than it has to be but that is up to you the designer.
Here is my problem and I do not know where and how to start to search about this.
In a MS Access database users will have a list of records returned from a query. Let's say employees which are active (employed). This table has a related table let's say departments (related through departmentID in both table).
What I want to do is to make form (or something else which would do the same job), where user will select some records (probably with checkboxes associated with each record) and there will be a single combobox with department names. When user selects a department name, its departmentID should be saved into departmentID field of these records.
I have created a form with a query of active employees (form with multiple items). And put an extra field in Detail section with a checkbox. In Form footer I have a combobox with Department names and IDs (not shown to user), and a button to save values.
I have to now figure out, how to select all rows/records with a checked checkbox and update them. I am by the way familiar with VB and SQL.
I would appreciate any idea/knowledge on how to solve this.
An extra field in the Detail section won't help you if you don't link it with a data field in the displayed table. If you can do that, then you have simply to make a VBA function to update all selected rows, and refresh the recordset.
If you cannot modify your table, you'll have to create a new table with just the key columns of your master table, and manage it via VBA. Better to use the first option if you can, it pollutes your schema, but in most cases that won't be a problem for an Access database.