简体   繁体   中英

Microsoft Access 2010 lag in continuous form header subforms

I am a research student working on an access database where I have created a continuous form that is to be used in a sort of scrolling electronic health record format. The header includes information about the patient and the continuous form aspect is a series of patient visits. In the header, I have a few subforms, which populate based on linking on the patient_ID number which is posted in the header (generated by vba macro such that previously reviewed patients aren't revisited). These subforms seem to significantly lag such that they the results from the previous patient stick around going into the next one. The subforms contain user-selected pertinent data. Each form has its own table. They are linked primarily based on patient_ID.

I have tried:

  1. macro on the header detail: on click, refresh. - seems to work, but not very elegant/intuitive
  2. macro on the main form - same as above but on load, click, got focus, lost focus, open, activate -- none of them seem to do anything.
  3. forced requery via vba (see below) on opening/etc of the form. Neither way has worked. Tried to run these on opening the header form.

    Public Function RequeryMain() Dim frmMain As Form Set frm = Forms("FRM_continuous_reports_patient") frm.Requery End Function

    Public Function RequeryHeader() Dim frmHeader As SubForm Set frmHeader = Forms("FRM_continuous_reports_patient").FRM_continuous_header_working frmHeader.Requery End Function

In the end, it is frustrating for users to have to click to clear the form for new entries. It works otherwise.

The end goal is for the form to open and have all the subforms load based on the newest patient_ID. This would likely have to involve a staggered load: (1) VBA script selects the next patient based on certain characteristics and passes the patient_ID to the main form; (2) load main continuous form based on patient_ID submitted to it; (3) load the header subforms and any pertinent data within (although should be blank for the first time these are seen); (4) on completion, back to (1).

From what I understand, this is already how it is working, however the subforms are loading too quickly? How can I fix this?

Hopefully someone can help explain how to remedy this/correct any misunderstandings I have about the mechanics of forms.

I know this will sound odd, but subforms actually load before parent form. Lag in subform display is not something I have encountered. Code should not be needed and likely will not correct. Must be something about the form/subform design, maybe their RecordSource. Would have to examine db to determine.

It is not necessary to create form objects in VBA just to requery. Is code behind the main form? Me.Requery will be enough for the main form. I always give subform container a name different from the object it holds, like ctrPatient. Then just Me.ctrPatient.Requery .

Why not put subforms in Detail section?

To answer your questions, and provide a condensed version of the logic referenced at: https://accessexperts.com/blog/2014/01/07/delay-loading-subforms-in-access/

is to:

  1. In design view, set your subform SourceObject to "" (and save your form)
  2. When you are ready to show the subform, just execute: Me..SourceObject = ""
  3. When you are ready to navigate to the NEXT patient, clear the subform link: Me..SourceObject = ""

Now that should solve the issue of out of sync data between the main and sub.

You don't need to use the CASE statements, but they operate as if you had a bunch of "If" / "ElseIf" all nestled together -- except the CASE makes it easier to follow. It basically gets a value from a variable (ie Select Case MyVariable); then checks to see if it equals what you want (Case 1, Case 2, etc.), and if so, does whatever you code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM