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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Refresh/update a userform in Word VBA 2000

Status
Not open for further replies.

wiseguy62

Programmer
Aug 13, 2002
5
CA
I am trying to udate a user form just before I update a Word document. I try to change the text and colour of a text box but nothing changes unless I step through the program. Any ideas?

Public Sub FillForm(btnOKClicked As Boolean)
'change status text box
frmQuoteClosing.txtStatus.BackColor = vbGreen
frmQuoteClosing.txtStatus.Text = "Please wait while the document is being filled out"
Application.ScreenRefresh

Call FillForm1(btnOKClicked) 'this routine updates the word document

End Sub
 
wiseguy62,

How is the FillForm procedure being called? I tried to re-create your setup with a Userform, TextBox and CommandButton. I created a procedure that changes the TextBox's background color and assigned this to the CommandButton_Click event handler. This worked as desired.

Regards,
M. Smith
 
Actually, the user clicks a command button called cmdSaveExit. This, calls FillForm which basically writes a bunch of text to a Word file using FillForm1. Once this finishes, cmdSaveExit saves the Word document then unloads all the user forms. The problem might have something to do with the fact that I unload the form? Here is the code:

Sub cmdSaveExit_Click()
If blnSalesPersonSelected = False Then Exit Sub 'exit if sales person not selected
FillForm (True) 'fill in the form
Call SaveFile(frmQuoteClosing.txtCompany.Text) 'save the current open document
Unload frmQuoteMergeNotes
Unload frmDocketInfo
Unload frmDate
Unload Me
End Sub
 
I don't see a problem, per se, with the way you are unloading the forms. How quickly does the frmQuoteClosing form disappear after clicking the cmdSaveExit button? If the called procedures are fast there might not be enough time to update the TextBox. As an experiment, try adding the following lines between the calls to FillForm and SaveFile:

Code:
Do While Timer < Start + 3
  DoEvents
Loop

where Start is DIMensioned as Long and 3 is the seconds of delay, which you can, of course, change.

Let me know how this turns out.

Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top