Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program going to fast? 2

Status
Not open for further replies.

XTnCIS

Programmer
Apr 23, 2002
57
US
The short example of what I'm doing is:
...
Me.CCBR_subform.Visible = False
...
'Connect to Oracle via ADODB connection to get recordset
Set Me.CCBR_subform.Form.Recordset = rs
If rs.RecordCount > 0 Then
Me.CCBR_subform.Visible = True
End If

----------------------
Problem is that the subform doesn't disappear until after the ADODB connection is complete. If I put a msgbox after setting CCBR_subform.visible = false (or if I break the code there), it actually happens.

If though, I don't make the program stop at this point, the rest of the code gets going and the subform doesn't disappear until after the recordset assignment.

I remember way back when, when you had to put pauses in your code because the computer worked too fast for the programming languages. I don't even see a way to do that in Access VBA.

I don't want the user to prompted with a msgbox or a program break or something, I just want the subform to go away and not come back unless something exists in the recordset.
 
Try this; it's not pretty, but it should work. I can't help thinking there is a much better way to achieve what you want, but if you want something "quick and dirty", here it is!!

Brian



...
Me.CCBR_subform.Visible = False
...
'Connect to Oracle via ADODB connection to get recordset
Set Me.CCBR_subform.Form.Recordset = rs
If rs.RecordCount > 0 Then
Me.CCBR_subform.Visible = True
'**********************************
'Here is the pause; you may need to adjust the number to 'get the duration you want.
Dim i as long
For i=1 to 100000
next i
'***********************************
End If
 
Thanks for the help, but I tried x = 1 to 500000000 and it gave me a second or two, but still didn't let the visible=false take affect.

Does anybody else have an idea?
 
No no no. One line:

DoEvents



That's all you put in there, after the .Visible = True
 
Sorry for possibly stating the obvious or unecessary.

Play about with the Echo Method and Repaint Method.

Bill
 
Thanks foolio12... works fine.

I'll have to read up on that now.
 
another loop to consider:

' this loop will pause, on the average, .5 seconds
' you can nest it in another loop to pause 'n' seconds.
dim StartTime as now
starttime = now
do while starttime = now
doevents
loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top