Refresh unbound textbox

A

alex

Refresh unbound textbox

Hello,

Using Access ’03…

I have quite a bit of VBA code that runs a variety of queries.
Between all of the SQL code, I display information to the user in an
unbound textbox on the form. Something like this:
‘’’’’’’’’’’’’’’’’’’’’’’’’
Sub RunQueries()
Me.unboundTextBox = “About to run queries”

Me.unboundTextBox = “Running Query A”
Docmd.runsql(queryA)

Me.unboundTexBox = “Running Query B”
Docmd.runsql(queryB)



Me.unbountTextBox = “Running Query Z”
Docmd.runsql(queryZ)

Me.unboundTextBox = “Finished queries”
End sub
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’

The problem is that (on some occasions) the queries will run without
the text being displayed; i.e., the textbox will display “About to run
queries” and then will display “Finished queries.” I thought the
problem was that the queries ran so fast, I just couldn’t see the
textbox change, but this happens even when it takes a few moments for
the queries to finish. E.g., I can see the queries running in the
lower left-hand status bar, but the text will not change.

It’s almost like I need to put in a break (like a msgbox) to get the
textbox to refresh—which works strangely enough? Or possibly to set
the focus back to form/textbox?

Any thoughts?
alex
 
J

Jeff Boyce

Alex

Not sure why ...

If this is an intermittent issue, that makes it harder to diagnose!

As a test, maybe you could try adding in something like the following after
each Me.xxxx (untested):

Me!unboundTextBox = "Running Query A"
Me.Repaint

....

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

Refresh unbound textbox

Hello,

Using Access ’03…

I have quite a bit of VBA code that runs a variety of queries.
Between all of the SQL code, I display information to the user in an
unbound textbox on the form. Something like this:
‘’’’’’’’’’’’’’’’’’’’’’’’’
Sub RunQueries()
Me.unboundTextBox = “About to run queries”

Me.unboundTextBox = “Running Query A”
Docmd.runsql(queryA)

Me.unboundTexBox = “Running Query B”
Docmd.runsql(queryB)



Me.unbountTextBox = “Running Query Z”
Docmd.runsql(queryZ)

Me.unboundTextBox = “Finished queries”
End sub
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’

The problem is that (on some occasions) the queries will run without
the text being displayed; i.e., the textbox will display “About to run
queries” and then will display “Finished queries.” I thought the
problem was that the queries ran so fast, I just couldn’t see the
textbox change, but this happens even when it takes a few moments for
the queries to finish. E.g., I can see the queries running in the
lower left-hand status bar, but the text will not change.

It’s almost like I need to put in a break (like a msgbox) to get the
textbox to refresh—which works strangely enough? Or possibly to set
the focus back to form/textbox?

Any thoughts?
alex
 
D

Dirk Goldgar

Try inserting DoEvents after changing the value of the text box, before
running the next query. For example:

Me.unboundTextBox = “Running Query A”
DoEvents
DoCmd.RunSQL queryA

Me.unboundTexBox = “Running Query B”
DoEvents
DoCmd.RrunSQL queryB


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

Refresh unbound textbox

Hello,

Using Access ’03…

I have quite a bit of VBA code that runs a variety of queries.
Between all of the SQL code, I display information to the user in an
unbound textbox on the form. Something like this:
‘’’’’’’’’’’’’’’’’’’’’’’’’
Sub RunQueries()
Me.unboundTextBox = “About to run queries”

Me.unboundTextBox = “Running Query A”
Docmd.runsql(queryA)

Me.unboundTexBox = “Running Query B”
Docmd.runsql(queryB)



Me.unbountTextBox = “Running Query Z”
Docmd.runsql(queryZ)

Me.unboundTextBox = “Finished queries”
End sub
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’

The problem is that (on some occasions) the queries will run without
the text being displayed; i.e., the textbox will display “About to run
queries” and then will display “Finished queries.” I thought the
problem was that the queries ran so fast, I just couldn’t see the
textbox change, but this happens even when it takes a few moments for
the queries to finish. E.g., I can see the queries running in the
lower left-hand status bar, but the text will not change.

It’s almost like I need to put in a break (like a msgbox) to get the
textbox to refresh—which works strangely enough? Or possibly to set
the focus back to form/textbox?

Any thoughts?
alex
 
P

Paul Shapiro

You could try adding Application.DoEvents after your code assigns the text
values. That forces the UI events to be processed. Otherwise Access
schedules the UI events in and among the computational work.
 
A

alex

Alex -

Add a Me.Repaint in the code after each textbox update.

--
Daryl S














- Show quoted text -

Wow, I've never got this much help this fast!
I just did some preliminary testing and it looks like me.repaint
works. I'll post back if that doesn't hold true.
I appreciate the help as always.
alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top