Access 03 Parent and Child linkage issue - ms-access

I have an Access database (2003 Access) that has a main form linked to a table (tblClientMaster) and a series of subforms. TblClientMaster has a series of unique client names. You can then click on each subform (there are labels with each name that can be clicked on which will open the subforms) and they should filter based on the client you have selected on the main form. I can't filter the subforms based on additional criteria, but I've basically given up on this for now (filter the subform results based on the value of a field on the main form along with an additional parameter, like product name. Every attempt I've made has utterly failed and posting questions on here about it generated no responses, so I've abandoned this for now.)
I am focusing on getting a single subform to work right now (fsubBenCalcs). Each record of the tblBenCalcs has the name of the client which matches the client name listed on tblClientMaster. When you click the BenCalcs subform, it filters the results by client and you can cycle through each record that exists with the same client name. (for instance, Company ABC has 25 calculations that have been completed. Once you select Company ABC, you can click on the BenCalcs subform and it will display the first record and you can cycle through the other 24) However, when I open the main form, it asks me to enter the Parameter value "tblCalculations.Forms!frmMain!ClientName".
First, I don't understand why it is looking for tblCalculations.Forms when tblCalculations is a stand-alone table containing the data for fsubBenCalcs. Second, when I load the main form, it should be completely independent of any value on fsubBenCalcs. Only when I load fsubBenCalcs should it look to the main form for the name of the client.
On the Subform/Subreport (when I go into properties on the main form and find the BenCalcs subform) it has the fields "Link Child Fields" and "Link Master Fields". For these, I put [Forms]![frmMain]![ClientName] for Link Child Fields. For Link Master Fields I just have ClientName.
I have to imagine something is wrong in here, but I haven't been able to come up with the correct way to link these forms. I would appreciate any help or guidance on this. I hope I was clear enough in my description.

Subforms (child) must link to the main form (parent). Subforms are not designed to refer to each other in a partent-child relationship.
You can hack this as follows:
Put a text-box on the main-form (i.e., NOT any of the sub-forms) with the following control source:
=[subForm_1].[Form]![FieldYouWantToLinkBy]
Then, in your "child" sub-form, use the parent-child linking fields to refer to this textbox.

Related

How Do I Make a Subform Controlled by Report (Which is Controlled by a Query) Update After Records Are Added?

I recently took a duty position that requires me to track our administrative actions. Previously, the office had tracked them on an Excel spreadsheet, and the historical data was corrupted/missing. So I have built a database in Access 2010. I designed the database to display a main form that provides an overview of each action, but decided to require most of the data to be added or updated on specific data entry forms. My question relates to two subforms on the main form that I cannot get to update after data is entered into the tables. Here are specifics:
1) The main form is the case detail form, and each case has a unique case ID number that links most of the forms and tables.
2) The Case Detail Form has two subforms. One displays the names of the people involved in the case (this is the Subject Subform). The other displays the case history entries (this is the Case History Subform).
3) Both of the subforms are supposed to work the same way. Each is populated by a report which displays the information in its corresponding Subform. In turn, the reports underlying each Subform are based on a query that selects the records to display based in the case number.
4) New data for the subforms cannot be entered on the Case Details Form. Instead, the user can press a command button which launches a separate form that allows the user to enter either subject details or to enter a case history update. Once the user enters the data, he or she clicks A Save Record button, which saves the record and closes the form window. Everything seems to work fine up to this point.
5) However, I've now been working on this project for two weeks (as time permits), and I am still not able to make the two subforms update automatically. If it's a new case record, the user can make the Subforms update by using the navigation arrows to leave the main Case Details Form and then returning to it. If it's an established case record, a refresh button that I have added to the main Case Details form will cause the two subforms to update.
As I've tried to make this work, I've tried a number of approaches that I've found on various boards. Right now, I have:
A) The Subject data entry form has a Me.Requery statement in After Insert Event Procedure
B) The Subject data entry form has a SaveRecord and a CloseWindow command that are executed when the Save Record Button On Click event is triggered.
C) The main Case Detail Form has a executes a Me.Case_Subjects.Form.Requery when the GotFocus Event Procedure is executed.
I apologize for the lengthy question and explanation. I'm an Army officer and a little out of my depth with this. I would greatly appreciate any help anyone might be able to offer.
Best regards!
I'm not sure having understood everything but I try to give you some suggestions about what to try.
If I'm not wrong both form and subforms have the case ID as field so when you created the report you should have put them in "link" by the wizard (you can set it manually after but it's a bit more tricky).
Did you do this? This makes the form / subforms update when you navigate them.
Please note that there must be a relation between the underlaying tables to guarantee that the reports / forms moves together!
This applies to the query too, just remember to include the ID field int the queries.
If you don't want to see the ID (in case you use an autonumbering id) you can set it Not Visible.
In case you don't want to link the two tables with a relation there is another solution but it's a bit more tricky and, if it's not your case, I don't want to make confusion.
Let me know if you solved.
Bye
Firstly, the line Me.Requery should be on the After Update event, not the After Insert event. Secondly, you will then need to change Me.Requery to Me.[insertsubformname].Requery.
As the user above said, you will need to ensure that you have created your database relationships properly, however if you used the Insert Subform, it should've asked you what you wish to use as your link between the forms.

Changing Record of Subform in MS Access

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?

Autofill value in subform based on value in parent form

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.

Selecting a record in Access Subform

I have a form in Access 2003 that contains 2 subforms. The first is in datasheet view and is only 2 fields, SiteID and SiteName, so a list of many sites for one record in the parent form. The second subform is the same datasource as the first, but in single form view, so it shows all the site fields for one site in a single form. The idea being that I have a list of the site names on the left and I want to then click on one and have its OnCurrent event filter the subform on the right to show all the fields in that record (for that site).
This seems like a fairly simple thing to do but I can't figure out what code (docmd.gotorecord?, filter?, programatically change the subforms query and then requery etc) is the best to use... and how to make it actually work.
Any help appreciated.
Have a look at the Customer Orders form in the Northwind sample database (NWind.mdb) that ships with every version of Access or can be downloaded http://www.microsoft.com/downloads/details.aspx?familyid=c6661372-8dbe-422b-8676-c632d66c529c&displaylang=en
I think you will find it does what you want.

Many-To-Many MS Access Form With Checkboxes for All Options

I'm working on a Microsoft Access application for a summer camp to track which entities have signed up for which activities. There is a form for editing an entity's information. I would like to add to that form a list of all activity options. By each option should be a checkbox. When the checkbox by an option is checked, a entry should exist in the many-to-many junction table linking the entity with the activity.
Google offered some examples of building many-to-many forms but none (at least that I found) showing how to provide a full list of options with checkboxes.
How would I do this?
Database Table Layout:
Entity (EntityID, first name, last name, etc.)
Activity (ActivityID, activity name)
Entity_Activity (EntityID, ActivityID)
One way to do this:
Create a new entry in the Activity
table.
Manually insert one checkbox
per activity on the form.
Register
an onClick handler on each checkbox
that adds the appropriate row to the
junction table when tje checkbox is
checked and removes the appropriate
row when the checkbox is deselected.
I was hoping for an approach that didn't require manually laying out the form. With this method, every time a new activity is added, the form must be modified. Oh well....
Instead of check-boxes, the more natural way to do it with MS Access would be to have a list of activities (in a sub form) that each entity is signed up for. Activities would get added from a pull down list (and perhaps an Add button), and removed with a Remove button. With a clever query, you limit that list to only activities that the entity doesn't have yet.
Alternately, you could go with the checkboxes, but you'll have to modify your table layout slightly. Entity_Activity would need a third field (SignedUp, yes/no). You would then have to populate every Entity_Activity combination when you created a new Entity. However, if you should happen to add another Activity later on, you'll have to go through some hoops to get all the existing Entity's entries updated.