The issue I am having is related to code executing when my main form is being loaded. I have a large number of things that happen: text box back colors standardize to grey, command button captions change, network drives are mapped, file objects are checked for last modified date and written into a table....
When I put the code on a command button, it all works perfectly. When I put it in the form Load or form Current, it throws runtime 2475 indicating that the form has to be active for the "strFormName = Screen.ActiveForm.Name" to be used. While it seems obvious, I can't seem to figure out which event that I can put this in that will still work...otherwise I need to change the code so that it will somehow work.
code snippet ---
Expand|Select|Wrap|Line Numbers
- Georeport = Array("BRAZIL", "CANADA", "MEXICO", "SSA", "UNITED_STATES")
- intcounter = 0
- While intcounter < 5
- reportname = Georeport(intcounter)
- rst.FindFirst ("[Support File Name] LIKE 'Identity_Management_Comp_imt_overview_" & reportname & ".csv'")
- LastMod = rst![Support File Modified Date]
- MonName = rst![MonitorName]
- ButName = rst![CommandButtonName]
- If LastMod < Date Then
- strFormName = Screen.ActiveForm.Name
- Forms!frm_Main.Controls(MonName).BackColor = 4678655
- Forms!frm_Main.Controls(ButName).Caption = "Recheck"
- Else
- strFormName = Screen.ActiveForm.Name
- Forms!frm_Main.Controls(MonName).BackColor = 65280
- Forms!frm_Main.Controls(ButName).Caption = "Replace"
- End If
- intcounter = intcounter + 1
- Wend