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

Conditional Formatting in form waiting until end of code to display 1

Status
Not open for further replies.

saraUSIT

Programmer
Jul 15, 2009
20
0
0
US
I am opening a form in a module that displays data that the user has to confirm is ok. Some of the fields in the form have conditional formatting that changes colors depending on the results. After the docmd.openform - there is more code and a msgbox that comes up that the user has to select "Yes" or "no" - the problem is that the data in the form that has conditional formatting does not display until after the user selected a button on the msgbox and after all the other code has run in the module. I tried inserting DoEvents but that did not help. Is there anyway to have the program first finish displaying the full form before it goes to the next step and opens the msgbox?

Thanks
 
The form order of events:
Open ? Load ? Resize ? Activate ?

The open event occurs before the first record displays
The load event occurs after the records display

Move it to the load event or to the activate event
 
In which code is the MsgBox ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The user is running code that does multiple things - it's importing data and later on it will update a table with the imported data.
After the module runs the imports - it opens the form which is meant to display to the user the counts of items that will get updated if he confirms "Yes" when the msgbox pops-up immediately after viewing the form. The point was that the user will see the open form on his screen and if the data is red (which would happen if the numbers are in the range set in the access built-in conditional formatting) - he would hit "no" on the msgbox that pops-up which is immediately after the open form in the module and then the program would print out the form and not continue running the update statements in the module.
But what is happening is that the fields that have the conditional formatting in them - do not display anything in them - they remain blank until after the msgbox buttons were pressed (and at that time it's too late)
Thanks for your help.
 
So, the MsgBox and the update code should be in the Current event procedure of the form, doesn't it ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The way I currently have it - is that this whole module is running from a separate macro. The form that displays the results is in DS format and the msgbox is just the next line of code in the module.
 
I have tested this. If I include do events then the conditional formatting renders, if not then the CF does not render.

Public Sub TestOpen()
DoCmd.OpenForm "frmTest"
DoEvents
MsgBox "Test"
End Sub

Please show your code with where you added do events?
 
MajP, here is my code:

Public Function runSheets()
'other lines of code'

DoCmd.OpenForm "SupplierResults", acFormDS
DoEvents

msgResponse = MsgBox("Does the report look OK -Continue running program?", 4100)

If msgResponse = 7 Then
DoCmd.PrintOut acPrintAll
Exit Function
End If


End Function


Only the fields that do not have CF appear in the form when the msgbox displays, the other fields remain empty until after a button is selected on the msgbox.

Thanks for your help!
 
Is there any way to make the code pause and not go on to the next step until the form finished populating?
 
I do not know if this will make a difference, since do events does not seem to work. But if it is a timing thing then maybe putting a delay will help.
Code:
Public Sub PauseThenMessage()
  Const PauseTime = 2
  Dim start As Long
  DoCmd.OpenForm "SupplierResults", acFormDS"
  start = Timer    ' Set start time.
    Do While Timer < start + PauseTime
        DoEvents    ' Yield to other processes.
    Loop
   MsgBox "do you ..."
End Sub
 
Thanks MajP!
I set the delay to 1 second and it actually worked! I wonder if the issue was that it was a calculated field and it still needed to do the calculation prior to the CF so it needed that small delay to process- I really appreciate your help!

Thanks again,
Sara
 
Glad it worked, I did not think it would.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top