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

[Control].Visible = True/False giving run-time error 91

Status
Not open for further replies.

Melagan

MIS
Nov 24, 2004
443
US
Does anyone know why the following code would work in Access 2000 but give RT Error 91 in Access 2003? The code is behind the opening form of an Access 2000 formatted DB.

Code:
Private Sub Form_Load()
    'When the database is opened display welcome user message.

hourglasson = True

'Display "Good Morning"
If Time() < 0.5 Then
[lblMorning].Visible = True
[lblAfternoon].Visible = False
[lblEvening].Visible = False

'Display "Good Afternoon"
ElseIf Time() > 0.5 And Time() < 0.75 Then
[b][lblMorning].Visible = False[/b]
[lblAfternoon].Visible = True
[lblEvening].Visible = False

'Display "Good Evening"
ElseIf Time() > 0.75 Then
[lblMorning].Visible = False
[lblAfternoon].Visible = False
[lblEvening].Visible = True
End If

End Sub

This is the first day I've run across this problem (migrating from Access 97). The current time of day is 3:20PM PST, so the "ElseIf Time() > 0.5 And Time() < 0.75" is evaluating to true. The highlighted line for the Run-time error is the bolded line in the above code. Again, this is only happening when the DB is launched in Access 2003 - it worked fine in Access 97 and Access 2000.

Any help is always appreciated, thanks!




~Melagan
______
"It's never too late to become what you might have been.
 
I believe I solved the issue, but I don't understand why the problem came up in the first place. Anyway, the solution was:

Move all of this code from Form_Open() to Form_Load()

Code:
Application.SetOption "Log Name AutoCorrect Changes", False
Application.SetOption "Perform Name AutoCorrect", False
Application.SetOption "Track Name AutoCorrect Info", False
Application.SetOption "ShowWindowsInTaskbar", False

Is it a bad idea to have things in both the Load and Open modules of a form?


~Melagan
______
"It's never too late to become what you might have been.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top