AppActivate Issue:

gold007eye

Registered User.
Local time
Today, 14:04
Joined
May 11, 2005
Messages
260
Could someone please help me figure out what I am doing wrong here?

When I open the database it keeps telling me "Run-time error '5'" Invalid Call or Procedure. I can't figure out what I have done wrong. In the "Tools/Startup" options I have the title set as "Financial Database" same as what I am using for the AppActivate command. Can someone tell me what I am doing wrong.

Also is there a way to automatically detect the title w/out using API?

Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Form_Open_Err
DoCmd.RunCommand acCmdAppMinimize

AppActivate "Financial Database"

DoCmd.RunMacro "Toolbars Off"

'On open set focus to combo box
[cboEmployee].SetFocus

If Time() < 0.5 Then
    [lblMorning].Visible = True
    [lblAfternoon].Visible = False
    [lblEvening].Visible = False

ElseIf Time() > 0.5 And Time() < 0.75 Then
    [lblMorning].Visible = False
    [lblAfternoon].Visible = True
    [lblEvening].Visible = False

ElseIf Time() > 0.75 Then
    [lblMorning].Visible = False
    [lblAfternoon].Visible = False
    [lblEvening].Visible = True
End If

Form_Open_Exit:
    Exit Sub

Form_Open_Err:
    If Err = 10 Then 'Issue with AppActivate
        Exit Sub
    Else:
        MsgBox Err.Number & " - " & Err.Description
        Resume Form_Open_Exit
    End If
End Sub
 
What is the purpose of

If Time() ... The Time function doesn't work the way I think you are thinking it does.
 
The Time() part is working fine. Been using this layout for yrs. It's the AppActivate that isn't working. It works on other forms; just not this one. And it was working on this form earlier this morning. That's why I am baffled.
 
I'm not sure about your error, but for your last question:
Code:
CurrentDb.Properties("AppTitle")
 
I'm not sure about your error, but for your last question:
Code:
CurrentDb.Properties("AppTitle")

So Could I do something like ? And "AppTitle" do I put anything there or just leave it like that?

Code:
AppActivate CurrentDb.Properties("AppTitle")
 
I haven't used AppActivate before, but that should work fine.
 
Thanks for the input all. I figured out the problem. I had it written correctly; the problem was that for some reason a second instance of the database was running in the background and I had to End Process MSAccess.exe. Once I did that it was back to working fine again.
 

Users who are viewing this thread

Back
Top Bottom