MS Visual Basic Runtime Error 2494

Asked By 10 points N/A Posted on -
qa-featured

I have encountered this error while trying to use MS Visual Basic program. The following programming codes below are the codes that I am dealing with to fully continue to access it. Please provide some guides on how to resolve this issue.

If InputBox("password") = "thepassword" then
Docmd.OpenForm formname
Else
MsgBox "You are not authorized!",vbOKOnly
End if
Private Sub Open_Activities_Menu_Click()
If InputBox("Enter password") = "111111" Then
DoCmd.OpenForm Activities_Menu
Else
MsgBox "You are not authorized!", vbOKOnly
End If
End Sub
The issue is the DoCmd line where I get a message
Run-time error '2494':
The action or method requires a Form Name argument

SHARE
Best Answer by Amanda Morson
Best Answer
Best Answer
Answered By 0 points N/A #150087

MS Visual Basic Runtime Error 2494

qa-featured

Try to open form as below

Syntax

<Form Name>.Show

Example

Myfrom.Show  

Try to solve your problem as below 

 

Assuming you are going to open Activities_Menu  form

Private Sub Open_Activities_Menu_Click()

If InputBox("Enter password") = "111111" Then

Activities_Menu.Show

Else

MsgBox  "You are not authorized!", vbOKOnly

End  If
End  Sub

I am sure you can solve  your problem using the above code

Answered By 0 points N/A #150088

MS Visual Basic Runtime Error 2494

qa-featured

If the code doesn't work when it should, a possible cause is corruption of the database. To check if that is the actual cause, first create a temporary database and export this section of the code you posted into it and check to see if the error is still there. If the error does not appear again, then you will have to recreate a new database by exporting all objects from your original database into the new one due to corruption.

Login/Register to Answer

Related Questions