[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

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

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
wlwebb
Asked:
wlwebb
  • 2
  • 2
2 Solutions
 
mbizupCommented:
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
 
Dale FyeCommented:
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
 
wlwebbAuthor Commented:
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
 
mbizupCommented:
--->> 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
 
wlwebbAuthor Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now