I have a very simple form with a combo box that is populated by a query. A user selects the class for which they want to enter data from the combo box and the records (passing the selection from the combo box to another query) for that class are loaded into a subform.
However, when multiple users are accessing the database and another teacher selects another class from the dropdown and starts entering data, the subform for the first teacher requeries and brings up the class selected by the other teacher.
How do I avoid this?
I have split the database into frontend and backend.
It would seem that the combobox for selecting the class is bound to a field in a table. That is why it is updating for one user when another user makes a selection.
You should make this combobox unbound (=clear the ControlSource property).
It is not clear to me if you are already doing this, but the correct way of filtering by a field (class in your case) is to set LinkMasterFields (of the subform control) to the name of your combox control and LinkChildFields to the class field in the the underlying recordset of the the subform.
Related
I have a little problem here. I've a database with one table for Users and one for changes in progress for these users. They are in a 1:n relationship (one user can have many changes but one change only affects one user).
I output my users in datasheet view and have the changes in by standard collapsed subrows of this datasheet. The user shall be able to order the users by the number of ongoing changes matching the filters in this sub-form. Therefore i have to get the number of rows in this form.
in the subform i have a field called "Anzahl" (german for count) representing the number of elements currently shown in the sub-form and i have a field called SubFormAnzahl in the parent datasheet.
Now i try to access this field via
=[Changes_Subfrom].[Form].[Anzahl]
and i am getting a #Name? error.
Why does this happen and how can i prevent it?
With main form set as datasheet, it can't see subform textbox until subdatasheet is expanded, then the calc shows. If you want to keep main form as datasheet, options are:
set main form SubdatasheetExpanded property to yes.
DCount() domain aggregate function on main form - expression in query used as RecordSource or in textbox and must use same filter criteria applied to subform
DCount("*", "Changes", "UserID=" & [ID])
Otherwise, works with main form in Single view.
Mainform: has read only textboxes that reference a table (tblEmployee) that will hold flatfile upload data.
Subform: linked to "ID" field in tblEmployee table. Subform input data would input to tblEmployeeChangeover table. Subform is acting as an "update" tool. A user would look at the mainform, and if data needs to be updated, they would interact with the subform to do so. This is so tblEmployee is not modified, and the tblEmployeeChangeover can be used to email the new data only and also be used to run reports.
Both forms:
--have a field named ID, which is what they are supposed to be linked on. For example, if the flat file has ID of "3", then the subform should be "3" as well.
--Field names are identical for both main form and sub form, except subform has "_changeover" on them. So ID is ID for both forms. But "EmployeeSchedule" on Mainform is "EmployeeSchedule_changeover" on subform table and textboxes.
Problem: upload of flatfile seems to be fine. Need to be able to input data in subform that will be saved to tblEmployeeChangeover table. Whenever I try to input data into the subform and advance to a new record in the mainform:
-cannot input ID in ID textbox in subform
-which means data in subform is not linked to mainform textbox data
what do I do to get the subform to go to a "blank" form when the "next record" arrow is clicked on main form?
what do I do to make sure that the data is saved in the subform table when subform is updated?
If further info is needed, let me know.
Thanks,
PAT2B
I have a form that contains 4 subforms. The first subform gets data based on a selection in a combo box on the main form. The second subform gets data based on the first subform, and the third and fourth subforms get data based on the first.
It's a database contain information on research grants. I want to be able to pull up certain data based on a person's ID (multiple records to a person) or by the title of the grant. Names are working fine, but searching by title is giving me a hard time.
I've tried setting first subform's Record Source with a .RecordSource ="" line, but nothing updates at all when the code runs (the code is in the AfterUpdate event of the combo box containing grant titles). This one has me sort of stuck; I'm not sure if the dependencies among my forms have something to do with it.
Did you put a Form.Refresh in after you updated the recordsource?
I am creating a subform (in datasheet view) based on a query (qryClientEmployment) to display employment history for the client whose information is stored in the parent form (frmClientInformation). frmClientInformation is based on another query (qryClientInformation).
I have a filter on qryClientEmployment to select records based on the client ID field displayed on the parent form (frmClientInformation).
I WANT to be able to add new employment records to the subform and have access autofill the client ID based on the ClientID field on the parent form.
I have tried, without luck, setting the default value on the Client ID field on the table (which stores Client Employment history) equal to form!frmClientInformation!txtID.
I’m new to Access and am stumped.
When you are new to Access, it is nearly always best to use the wizard to create controls. In this case, it would have offered you the option of adding Link Child Fields and Link Master Fields, and these are what you need. You can edit these properties for the subform control, but you must be careful to select the control, not the form contained. Link child fields will be completed with data from the parent form master field, a misleading name, because the link master field can be a control. You can have multiple link child and master fields separated by semi-colons.
Do yourself a favour and change from datasheet to continuous form, you will have much more control.
I have a list box on an MS Access 2010 form that has its contents generated by a query. The list box lists new customer names; these names are the ones that are not listed in the Customers table in the DB.
The user can select a customer name on the list box and click a button to add that customer name to the Customers table.
Now, after the new customer is added to the Customers table, I want to refresh the table, i.e. I want to re-run the query that generates its contents. Is there a way to do this in VBA or by setting a property?
Thanks! :)
Listboxes, comboboxes, and forms/subforms have a Requery method that should refresh/requery/reload the underlying recordset.
Me.Requery 'Requery Form
Me.Listbox1.Requery 'Requery Listbox
Me.ComboBox1.Requery 'Requery ComboBox
Me.SubformControlName.Form.Requery 'Requery a subform
Choose the correct one above and change it to match the name of your control. I think you should put it at the end of your code on your button_click() procedure. In some scenarios you will place this code on a control's AfterUpdate event.