Asked By
patty white
10 points
N/A
Posted on - 05/31/2012
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
MS Visual Basic Runtime Error 2494
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
MS Visual Basic Runtime Error 2494
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.