Why do I have to delay or pause my code?

RFigaro

Registered User.
Local time
Yesterday, 20:31
Joined
Aug 5, 2012
Messages
18
In VBA I need to check the value of a field on a subform where the control source is =count([quantity sold]) to see if it is greater than 0. There is no problem as long as the subform is not dirty. If it is dirty and I set Me.Dirty = False the value of the count is not updated in vba unless I put a loop in my code to slow it down then it works fine even if I only pause for 1 second. The value shown on the subform for this field is updated and correct after the me.dirty = false.
Is there a better way of checking the count of the [quantity sold] field?

Here are some details of the form: The form is a basic invoice with line items in the subform. The subform is a continuous form that is loaded with line items so the user only needs to enter the quantity of items needed. I display the total number of line items ordered on the subform with a field where the control source is =count([quantity sold]) this all works fine.

Thank you for any help.
 
Wacky behavior of Access...

Yes, I have experienced Access needing data forced back into the table. In one spot I have a Multiple Items form which is suppose to be editable. The form has an enabled / disabled check box and I had to actually force the check box status into the FE DB else subsequent code was not guaranteed an accurate representation of the actual UI the person thought they submitted. I wired this logic onto the Checkbox field control:

Code:
Private Sub addpartrecordflg_AfterUpdate()

  'This will force the UI change back into the table
  If Me.Dirty Then
    Me.Dirty = False
  End If

End Sub
Another source of "timing trouble" in Access / VBA was in a multiple items form Cancel events getting sent when Esc is pressed. I had to eat up the extra Esc keystrokes in the button that Esc is connected to with the following code:

Code:
  'Flush keystrokes out of the buffer so that close via Esc does not generate an error msg
  DoEvents
  DoEvents
  DoEvents
One DoEvents was not enough, not even two... THREE seems to be adequate at eating up all of the Esc's. Before I started adding them, randomly the VBA debugger would come up offering to stop execution. Again... (shrug)
 

Users who are viewing this thread

Back
Top Bottom