473,396 Members | 2,115 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,396 software developers and data experts.

Refresh an unbound form

patjones
931 Expert 512MB
Hi:

There are many posts both here and on other forums about this topic, but nothing quite matching what I have...

I have an unbound form called frmChecks which displays information by means of an ADO recordset. Whenever I search for something, I have a globally defined subroutine, UpdateForm, that uses a SQL string to pull information into an ADO recordset and display the data on the form.

I also have a form called frmModify which exists for the purpose of editing the data on frmChecks. It opens up with the same information that is in frmChecks. The user can make any changes they want, click a "Save" command button (which causes the UpdateForm subroutine to run), and frmModify closes to take the user back to frmChecks.

The problem is that the changes don't appear on frmChecks. The bizarre thing is that when I breakpoint my code and step through it to see what the problem is, it all works fine...frmModify closes and frmChecks appears with the correctly modified data. It's only when I try to do this under normal execution that it doesn't work properly.

Why would it function correctly in one circumstance and not the other? I can post code if need be. Thank you...
Aug 1 '08 #1
8 5866
RuralGuy
375 Expert 256MB
I need to start by asking why frmChecks is unbound?
Aug 2 '08 #2
Stewart Ross
2,545 Expert Mod 2GB
Hi. Access uses a fairly slack approach to screen refresh, so your form update sub is likely to need to repaint the screen (using the form's repaint method). Repaint updates the screen, not the underlying recordset - but as you have updated that yourself repaint should then force the changes made to be reflected on screen.

-Stewart

Remarks
Microsoft Access sometimes waits to complete pending screen updates until it finishes other tasks. With the Repaint method, you can force immediate repainting of the controls on the specified form. You can use the Repaint method:

* When you change values in a number of fields. Unless you force a repaint, Microsoft Access might not display the changes immediately, especially if other fields, such as those in an expression in a calculated control, depend on values in the changed fields.

* When you want to make sure that a form displays data in all of its fields. For example, fields containing OLE objects often don't display their data immediately after you open a form.

This method doesn't cause a requery of the database, nor does it show new or changed records in the form's underlying record source. You can use the Requery method to requery the source of data for the form or one of its controls.
Aug 2 '08 #3
patjones
931 Expert 512MB
Hi. Access uses a fairly slack approach to screen refresh, so your form update sub is likely to need to repaint the screen (using the form's repaint method). Repaint updates the screen, not the underlying recordset - but as you have updated that yourself repaint should then force the changes made to be reflected on screen.

-Stewart
I have actually used Repaint (or tried to use it) - to no avail. In fact, I can't think of a circumstance yet where Repaint has helped me in anything. Even minimizing and maximizing the Access window doesn't do anything, and refreshing the form doesn't do anything.

To address why the form is unbound...I don't have a very good answer to that. Maybe binding it to a recordset is the way to go, and I will look into that. I'm just still perplexed about the current behavior; why does the program behave one way when I'm stepping through the code, as opposed to another way when it's executing normally?
Aug 2 '08 #4
RuralGuy
375 Expert 256MB
I'm just still perplexed about the current behavior; why does the program behave one way when I'm stepping through the code, as opposed to another way when it's executing normally?
That is almost certainly a timing issue. You might try some DoEvents in your code to give Access some cpu time to update the other form.
Aug 2 '08 #5
patjones
931 Expert 512MB
That is almost certainly a timing issue. You might try some DoEvents in your code to give Access some cpu time to update the other form.
That had occurred to me also, so I put a MsgBox line in the code right after the call to update the other form so I could wait a few seconds and see if that was indeed the problem, but it didn't matter.

What do you mean by DoEvents?
Aug 3 '08 #6
missinglinq
3,532 Expert 2GB
Access is asynchronous, which is to say, if given a series of commands, it starts to execute one, moves on to the next one and starts executing it, and so forth. It doesn't wait for the first command to be completed before starting the second one, and this can cause problems. An example would be a button that runs a series of monthly reports.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportA"
  2. DoCmd.OpenReport "ReportB"
  3. DoCmd.OpenReport "ReportC"
  4.  
Access will attempt to immediately send all three to the printer, and this may possible eat up all the memory assigned to your printing queue, causing an error to occur. The answer is to use DoEvents.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportA"
  2. DoEvents
  3. DoCmd.OpenReport "ReportB"
  4. DoEvents
  5. DoCmd.OpenReport "ReportC"
DoEvents returns control to Windows, allowing ReportA to complete printing before starting to print ReportB. It then allows ReportB to finish printing before starting ReportC.

DoEvents is an easy, safe bet when encountering what may be timing issues. Stepping thru your code works because when you step thru your code because you're completing one "step" before starting the next.

Linq ;0)>
Aug 3 '08 #7
patjones
931 Expert 512MB
Access is asynchronous, which is to say, if given a series of commands, it starts to execute one, moves on to the next one and starts executing it, and so forth. It doesn't wait for the first command to be completed before starting the second one, and this can cause problems. An example would be a button that runs a series of monthly reports.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportA"
  2. DoCmd.OpenReport "ReportB"
  3. DoCmd.OpenReport "ReportC"
  4.  
Access will attempt to immediately send all three to the printer, and this may possible eat up all the memory assigned to your printing queue, causing an error to occur. The answer is to use DoEvents.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportA"
  2. DoEvents
  3. DoCmd.OpenReport "ReportB"
  4. DoEvents
  5. DoCmd.OpenReport "ReportC"
DoEvents returns control to Windows, allowing ReportA to complete printing before starting to print ReportB. It then allows ReportB to finish printing before starting ReportC.

DoEvents is an easy, safe bet when encountering what may be timing issues. Stepping thru your code works because when you step thru your code because you're completing one "step" before starting the next.

Linq ;0)>
Thank you for that explanation; I understand what you are saying, and it gives me a plausible reason for why this may be happening. I'll try it out when I get to work tomorrow and let you know how it goes.

Pat
Aug 3 '08 #8
patjones
931 Expert 512MB
Access is asynchronous, which is to say, if given a series of commands, it starts to execute one, moves on to the next one and starts executing it, and so forth. It doesn't wait for the first command to be completed before starting the second one, and this can cause problems. An example would be a button that runs a series of monthly reports.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportA"
  2. DoCmd.OpenReport "ReportB"
  3. DoCmd.OpenReport "ReportC"
  4.  
Access will attempt to immediately send all three to the printer, and this may possible eat up all the memory assigned to your printing queue, causing an error to occur. The answer is to use DoEvents.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportA"
  2. DoEvents
  3. DoCmd.OpenReport "ReportB"
  4. DoEvents
  5. DoCmd.OpenReport "ReportC"
DoEvents returns control to Windows, allowing ReportA to complete printing before starting to print ReportB. It then allows ReportB to finish printing before starting ReportC.

DoEvents is an easy, safe bet when encountering what may be timing issues. Stepping thru your code works because when you step thru your code because you're completing one "step" before starting the next.

Linq ;0)>
Good morning:

Unfortunately, the DoEvents strategy doesn't work. I actually inserted a DoEvents at a couple of different places in my code, to no avail.

What did work though, was putting the call to my UpdateForm subroutine in the Activate event for frmChecks. That ended up working perfectly.

Thanks so much for your help!
Aug 4 '08 #9

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

Similar topics

1
by: John Baker | last post by:
HI again: I have made 2 posts on this issue, and for some reason still haven't got the right result. I have a form which contains a number of totals. These totals use unbound control boxes and...
2
by: allyn44 | last post by:
Hi--I have an unbound form that either edits an existing record or creates a new one and then refreshes a subform that views the record(s) chosen. What I would like to do from here is go to the...
6
by: Tim Marshall | last post by:
Here's the situation. A form, frmSetUp, with a subform control called subExplain with a source object form frmSetUpSubDefineSides. The source object is a bound form, displaying a few records, no...
5
by: Andrew Chanter | last post by:
I have a situation where I am using an unbound dialog form to update data in an Access 2002 split back end / front end scenario. The data update is done via an ADO call (direct to the back end...
7
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output...
4
by: Wilkesy | last post by:
Hi all, This is really begining to do my head in!!! I have a query that im trying to run, but i want it to refresh a subform, not open up into a new window. I have a CD database and so far i...
4
theaybaras
by: theaybaras | last post by:
Hi All... I've read both of the requery discussions I could find... Refresh ComboBox After Adding New Values via a Seperate Form and refresh a form but am not quite able to get this to apply...
7
AccessIdiot
by: AccessIdiot | last post by:
This is driving me nuts. I have an unbound textbox (txt_SumSize) in my subform that holds the total of a field (Debitage_Size_Quantity)seen in datasheet view (control source =Sum(). I have an...
5
kcdoell
by: kcdoell | last post by:
Hello: I thought I was done with this one but a user who is testing my DB just pointed out a problem. I used the following in the afterupdate event: Private Sub...
7
by: Kevin Wilcox | last post by:
Hi I'm trying to emulate, within access, the gantt chart timeline / task planner aspects of ms project. Creating the chart on the form has been easy enough; I use a series of unbound text boxes in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.