Solved

Access - Tabbed Form - Requery works if Step Thru.  Errors if Run without Step Thru

Posted on 2013-02-06
5
305 Views
Last Modified: 2013-02-06
Hello All

I have a Strange Thing Happening.........  At least to me it is.........

I have a Tabbed form with each Tab having a Subform Control on every tab....

One of the tabs has a Subform with 6 of its own Subforms.  On the 6 subforms (all Single View) there is an unbound field where I calculate some info.  

Info from those 6 Subforms via Vb code gets used in some other Tabs Subform Controls.

The First tab of my form has an Unbound Textbox where a user inputs one piece of info.  That starts all of the computation via my After_update event of that textbox.

Now then, If I don't put any Breaks in my code it errors out when getting the Computed field from one of those 6 subforms.

HOWEVER, if I put a Break in all the code just before the line where it errors and then step through everything line of code line by line it all works............it is as if just running it happens too quick for those subforms to internally update before the code to get the info for the other forms processes........

Is there a solution to this???????
0
Comment
Question by:wlwebb
  • 2
  • 2
5 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 450 total points
ID: 38858888
What is the exact error?

Stepping through things in the debugger slows the code execution down... which may allow anything happening outside of the current block of code to run to completion.

Just for kicks, try adding a messagebox statement immediateluy before whatever line is causing the problem.

Also try adding the following immediately before the problematic line of code:

DoEvents '<-- this causes a pause to allow other things to complete


You can even put DoEvents into a loop to wait for something specific to happen.  For example, if the error is caused by a Null in some field:

Do Until "" & [SomeThing] <> ""
      DoEvents
Loop
' The rest of your code

Open in new window

0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 50 total points
ID: 38858955
I was looking at your other question, and my guess is that the problem here has to do with you returning a recordset with zero records.

I think you need to address your perceived need for this subform which contains 6 other subforms, and the data you are collecting from those subforms.  Is there not an easier way to compute these sums than through 6 subforms?

Otherwise, you need to add the same test in the code for this issue that you did in the other question.
0
 

Author Comment

by:wlwebb
ID: 38859454
Mbizup

Wow that did it..........  ??????????????? Don't understand why????  other than it is processing faster than the update of the form can complete......

Fyed

Unfortunately I've reworked this a few times already trying to eliminate the need for the 6 Subforms....  I have not yet found a way to do that.  The info input on the main form that fires all the code selects which of the 6 subs get completed so that if a sub is not applicable it does not create any record for that type..... not even a record with a 0 in the amount field.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38859495
--->> other than it is processing faster

That's pretty much what is happening.

You have other events and 'stuff' going on with the various subforms.  The quick fix is through code (delays) ensure that all the 'other stuff' has time to complete before trying to do something that is dependent on it.

The best fix, of course is to streamline your forms, etc as much as possible to avoid these types of conflicts.
0
 

Author Closing Comment

by:wlwebb
ID: 38860317
Thanks Mbiz.... I am awarding Fyed 50 of the points because he does make a valid point within the discussion.  Thank you both.  

JUST FYI Fyed

I am pulling that code apart (again) to see if there is another way using the DAO recordset method that I can write....... and make mostly work..........  so.......I'll probably post some more that looks similar just trying to do it without using the Subforms again........

In that vein, is there a way within code to create a combobox without physically putting it on and having it update through the Subform ???   Likewise a query????
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now