473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

problem Making a Subform Controlled by a Report Update After Data Entry

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!
Jan 8 '15 #1
5 1456
twinnyfo
3,653 Expert Mod 2GB
Hi, Bryan,

Welcome to Bytes! I'm an Air Force civilian, so I'll try to talk slower for you Army folks! ;-)

I think I understand much of what you are saying and trying to do, but some of the language you use is not quite Access-speak (which grows over time) and you may be referring to things incorrectly (or your DB may be structured improperly). Either way, we will try to help with both. And, keep in mind, that I'll be "flying blind," as your DB is not in front of me.

First, because it is a little unclear as to what all is supposed to happen, rather than jump right into a solution, I will try to clarify what I think I understand you to be saying and request additional information and clarification from you on a few things.

1. Concerning point 3 above:
Each is populated by a report which displays the information in its corresponding Subform.
It would be highly irregular to have an access "form" populated via a "report". Do you actually have a "report" that is providing data for a form? in Access-speak, a "Form" is an object that displays data and allows the user to add, change or manipulate data. A "Report" is an object that only displays information and is not typically designed for user manipulation. Reports are typically printed after they are displayed. Forms help the user navigate through the mountain of data in the project.

2. You seem to be having problems with the forms saving/updating data properly. To begin, just in case you were not aware, in MS Access, whenever you are within a table or a bound form, any time you move between fields, the data is always "saved" automatically, and unless you cancel the save, moving to another record will save the entire record. So, as a general rule, there is never a need to "save" a record manually. Sometimes this is preferred, but seldom is it easy, and this type of activity is really beyond the average database construction.

So, that being said, if your tables are properly related and your forms properly constructed, the data entered for each record "should" update automatically. You mention
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.
My thought is if the subforms are properly related to the main form through the Case ID, any time a record is updated or added, the record should be automatically related to the Case ID. In that case an
Expand|Select|Wrap|Line Numbers
  1. Me.Refresh
or
Expand|Select|Wrap|Line Numbers
  1. Me.Requery
should be all that is needed (for example if you were "counting" associated records. However, your description is a little unclear as to what you want to do here.

Based on what you mention in A) through C) above, it doesn't sound like you are doing anything so strange that your date does not refresh in the display of the Case Form. However, you may have to force a refresh of both subforms when you refresh the main form.

Additionally, just on the surface, it does not seem that your table structures are way out of whack. Again, if the forms are built properly, all should be working (which it appears it "works", but it just doesn't refresh and update the display?).

Hope this can help us work toward a solution for you.
Jan 8 '15 #2
Sir,

I greatly appreciate your reply. And I definitely am grateful for you talking slower in this context. The answers to your questions are:

1) Each of the two subforms are controlled by a corresponding report that I created, which in turn is linked to a query. For example, the Case_Subjects query scans the Case_Subjects table for all subjects associated with a particular case number. The report then displays the Last Name, First Name, and Middle Name. This information then appears on the main form (Case Details Form).

The only real reason that I adopted this approach is because I read a posting on one of the web sites that I used to conduct research on this project that someone else had done it this way. So it seemed like a good way to me to reduce the ability of users to manipulate the data if they aren't supposed to. Unfortunately, that posting, which I am no longer able to find, did not go into detail about how he made it work. If there are other ways that I simply don't know about, I am definitely open to them.

2. As far as the database's ability to save entered data properly, it is working as it should. For example, if I add a subject to a particular case number, I start at the main Case Detail Form. I then click the Add_Case_Subject button, which pops up a Subject Record form. The form is autofilled with the Case Number from the main Case Detail form. The user cannot change that number and cannot change the date/time that the record was made. After they complete the form, the user clicks a Save Record button, which Saves the Record, closes, and refocuses on the Main Case Detail form. At this point, the two subforms (or reports--whatever they should be called) should update and display, but they do not. However:

a) if you minimize the form and open the table associated with the case subject form, the data is there, exactly as it should be;

but

b) if you run the query at this point, the data that was just entered does not appear. This in turn means it doesn't display on the report, which in turn means that it doesn't appear on the main Case Detail form. (Note that if you run the query or the report at this point, they do return results for previously entered data that was associated with a particular case number--so I'm sure the query and reports work properly--when they work).

3) I have tried Me.Refresh and Me.Requery, which didn't work. Although a Refresh button does work, so long as the Case Subject form that you have entered was not the first record for a case subject associated with that particular Case Number. So I thought that maybe I needed to alter the language to be more specific to the subform, and I added the following to the main form's GotFocus event:

Me.Case_Targets.Form.Requery

Does this help explain my situation any? I'm sorry that the postings are kind of long and that I may not be explaining things very well.

I very much appreciate your help though--Air Force people are very much more technically inclined than we Army folk!

Best regards!
Jan 8 '15 #3
twinnyfo
3,653 Expert Mod 2GB
Bryan,

Please bear with me, as point 1) above is particularly confusing:
Each of the two subforms are controlled by a corresponding report that I created, which in turn is linked to a query. For example, the Case_Subjects query scans the Case_Subjects table for all subjects associated with a particular case number. The report then displays the Last Name, First Name, and Middle Name. This information then appears on the main form (Case Details Form).
I still think you are mis-speaking, but I also think I understand what you are trying to say.

Your other points (I think) are addressed below, but using a different approach.

Please take a look at the attached Word Doc (I hope you like the Air Force Blue!), which has a visual of how your forms (and I use this term reservedly) "ought" to be structured. Note how the main form has the RecordSource of a Table (no filters or queries). I'm not saying that it can't have a query as a RecordSource, but by this setup, I want to demonstrate an important principle in relational databases.

When you create your Subjects Subform, note that the RecordSource is also a Table (no filters at this point). However, when you insert the subform into the main form, you establish the Master/Child relationship between the two forms (in fact, if your RecordSources and Forms are properly named and structured, MS Access may make some assumptions and establish this relationship for you). The same holds true for your Case History subform.

Why is this important? Well, when you move to a record in the CaseDetails form, the other two subforms will automatically filter out only the records associated with that Case ID! Additionially, when you are on a particular CaseDetail, whenever you add a record to either one of the subforms (at this point, no need for any pop-up forms), those records will be automatically associated with that CaseID.

Now, what should these forms look like? That is entirely up to you. Some people like to have a datasheet view for the subforms, or you could have a single form view that allows you to page through your subjects or history records. You could also experiment with a Split form, which would show both a datasheet view and a single form view on the same form. Those can be tricky, and, honestly, I don't have much experience with them, but I do know they are available for use.

The reason I explain this principle and this structure is because it precludes the need for any pop-ups and also precludes the need for a "save" button, as any time you complete a record, the data is already properly associated--simply clicking away from the record in question "saves" everything for you. This also precludes "requerying" the subforms, as they will always display all the records associated with that CaseID.

You can get fancy with these forms, too, if you want, and using a query for a RecordSource also works, as you can include various fields from other tables, as well. The key is the relationship between the three forms in question by use of the CaseID.

It sounds like you know enough about databases that this should all make sense.

Hope this hepps!
Attached Files
File Type: docx Form-Subforms.docx (19.9 KB, 348 views)
Jan 9 '15 #4
Sir,

Let me consider what you have told me. I think you raise some good points, and it sounds like I may have overcomplicated the database by adding layers that aren't necessary. I am going to attempt to double check a few things and alter a few thngs along the lines you suggest.

I will work it this weekend and see what happens. I will post more on Monday or so.

Have a great weekend, and thanks again!
Jan 9 '15 #5
twinnyfo
3,653 Expert Mod 2GB
Take care, Bryan! Have a safe weekend yourself!
Jan 9 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Maria | last post by:
One of my duties is to record student grades each report period(6). The tables in the database basically look like: TblStudent StudentID Name etc TblStudentGrade StudentGradeID GradePeriod
5
by: JJ | last post by:
I have a MainForm/subform1/subform2 setup that I thought was working but maybe I just hadn't tested it enough or broke it as I added more features. The database has 2 main tables: Companies and...
1
by: stranger | last post by:
I have an Access database on a shared drive. It is used by 8-10 people at any given time. I have a form set up to be opened in either "add" or "edit" mode. The problem I am having is the...
1
by: Trent | last post by:
I am in the design phase of a new database and am having a devil of a time with a subform. I have three tables that relate to problem - Suppliers tbl, Customers tbl and a SuppliersCustomers tbl....
3
by: bosmatthews | last post by:
I have a main form with a subform and a second subform nested to the first subform. The data entry property for all three forms (main, subform and sub-subform) is set to "yes" because I am intending...
1
by: NHNeedsHelp | last post by:
Hi, about to go nuts - I have a master form with 3 control buttons, user picks 1 for Const. job, 2 for Envir job and 3 for Geo job. Each button opens a subform containing the project number from...
20
by: hippomedon | last post by:
Hello everyone, I'm looking for some advice on whether I should break the normalization rule. Normally, I would not consider it, but this seems to be a special case. I have created an...
2
by: Monroeski | last post by:
I'm not a new user to Access, but I have been away from it for a while, so I'm making a lot of new user mistakes. I have a continuous form set up which displays performance measures for different...
2
by: tahirsatti | last post by:
I am facing some problem regarding designing of master detail data entry form in vwd,i have vwd 2012 and i have two tables one have primary key and second table have forign key i just want to design...
1
by: tinamiller1 | last post by:
I have a main form and data entry subform. When the main form is selected, the user can view records that exist in the main table in order to determine if they want to complete a data entry form or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.