Solved

VBA  RunTime Error 2494

Posted on 2011-02-16
9
2,017 Views
Last Modified: 2012-05-11
I have a password prompt form with an "okay" button.
When that Okay button is clicked, the action needs to check the password attempt vs the actual password, close the prompt form, open the next form and go to a control.

This is my code. It is on the 'On click' event of the button.............

Private Sub cmdAdd_Click()
    Dim stDocName As String
    stDocName = "USER_ADD"
   
   
    If Me.PasswordAttempt.Value = Me.PASSWORD Then
        DoCmd.Close acForm, "SECURITY", acSaveNo
        DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acWindowNormal
        Forms!USER_ADD!NAME_SHORT.SetFocus
    Else
        DoCmd.CancelEvent
        Forms!SECURITY!Message = "Password Incorrect"
    End If
   
End Sub

 vba image
I'm still learning vba and consider myself an amateur. Please tell me why this hates me so.
0
Comment
Question by:culpees
  • 5
  • 4
9 Comments
 
LVL 75
ID: 34911455
Not seeing the reason right off. Which Form is this code in?

mx
0
 

Author Comment

by:culpees
ID: 34911532
well, hey there.

The code is on the first form which is the password prompt form called "SECURITY".

The code is on the "Okay" button, 'on click' event, which would then open up the next form that requires restricted access.
This next form is called "USER_ADD". (it's a simple data entry form to add user access to the application.)

"SECURITY" password prompt form
0
 
LVL 75
ID: 34911577
can you upload ... code 'looks' ok ... ie syntax for DoCmd.OpenForm ...

mx
0
 
LVL 75
ID: 34911807
fyi ... I have to leave work soon ...will be back online a bit later ..

mx
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:culpees
ID: 34912084
IDK. I made a fake mdb for you and tested it and it worked. I pulled in the applicable forms & tables. But I can't get it to work in my real one. I get several different errors at different places with my real one. I don't know what's going on.

I tried decompiling a copy of it and it messed it up. So I'm back to my original.

I've got to go get my kids now, so I'll try to attach something that is showing errors or even print screens later.
0
 
LVL 75
ID: 34912626
ok Mom :-)

mx
0
 

Author Comment

by:culpees
ID: 34943613
Had to put this aside for a bit. Business trip plus some.

Will come back to this and provide all the info you need in order to get this resolved. Sorry I can't do it now. I would LOVE to get this problem resolved!! Will be about a week before I can return to this.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 34944700
k
0
 

Author Comment

by:culpees
ID: 35043780
Okay. I'm back.

I created a dummy mdb of the precise objects in the database which were tied to the problem code to share here. When I tried recreating the error in the dummy db prior to sharing it, there was none. It worked perfectly.

So I recreated the whole bleepin' database by importing all objects into a blank one and whoolah! All the code compiled fine. The old db had been corrupt, I guess.

All that time chasing geese. So I'm off to create a new thread on a new problem. Yippee!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now