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

STOP MACRO

Status
Not open for further replies.

qwerty70

Technical User
Dec 13, 2005
73
GB
Dear All,

I am having a problem dealing with macro. Here's the scenario: If a user logs to my database and has no outstanding task, I want the frmGeneral form to close and return to the main switchboard. The problem occurs when the user opens the frmGeneral again, the system pops up a dialog box with the following error:

Action Failed
Macro Name: mcLoginFilterCurUser
Condition: True
Action Name: RunCommand
Arguments: 2

How can I prevent this error? I just want the system to pop up a message "You have no outstanding task" only, irregardless how many times the user opens the frmGeneral.

Here's my code:

Code:
Private Sub Form_Open(Cancel As Integer)

    If (Me.txtAccessType = 3) And (Me.Recordset.RecordCount = 0) Then
        MsgBox "You have no Outstanding Task.", vbOKOnly, "Task Assignment Status"
    Else
        DoCmd.RunMacro "mcLoginFilterCurUser"
        DoCmd.OpenForm "frmGeneral", , "qryGeneral_FilterCurrentUser"
    End If

End Sub

Thanks in advance.

Regards,

qwerty70
 
How are ya qwerty70 . . .

Not trying to sound demeaning here, but if your using VBA to call a macro, [blue]why are you using macro's at all? [/blue] . . . [green]VBA[/green] should be your choice! . . .

In any case try moving your code to the [blue]OnLoad[/blue] event . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top