Results 1 to 8 of 8
  1. #1
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14

    Run-time error 2501 the Open form action canceled.

    Database is mdb, but using access 2007. Now getting the error 2501. See my code:
    Private Sub PASSWORD_LostFocus()
    Dim rst As Recordset
    Dim Pswd As String * 10
    Dim Entry As String * 10
    Entry = Left(Me("PASSWORD"), 10)

    Set rst = CurrentDb().OpenRecordset("tblPASSWORD")
    If IsNull(Left(Me("PASSWORD"), 4)) Then
    MsgBox ("ENTER A CORRECT PASSWORD or 'RETURN'")
    Me.Password = " "
    Me.Password.SetFocus
    End If


    Do Until rst.EOF
    If IsNull(Left(rst("PASSWORD"), 10)) Then GoTo KEEP_GOING
    Pswd = Left(rst("PASSWORD"), 10)
    If Pswd = Entry Then
    rst.CLOSE
    DoCmd.OpenForm ("frmTABLEMAINTENANCE")
    Exit Sub
    End If
    KEEP_GOING:
    rst.MoveNext
    Loop
    MsgBox ("ENTER A CORRECT PASSWORD or 'RETURN'")
    Me.Password = " "
    Me.Password.SetFocus

    End Sub
    Private Sub RTRN_Click()
    DoCmd.CLOSE
    End Sub

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    According to Google, this error can happen if the Form you're trying to open has VBA code that runs when it opens and encounters an error. It can also happen if there are compilation errors on the Form you're trying to open, even if the Form doesn't run anything.

    Try Compiling your code to check for VBA errors in other Forms and see what you find.

  3. #3
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    This is what happened when complied:
    Click image for larger version. 

Name:	7-17-2012 4-33-52 PM.jpg 
Views:	27 
Size:	95.8 KB 
ID:	8485

  4. #4
    jscriptor09 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    60
    I recommend finding what is DownTime. This error is something you would get if you are acalling a function and the function is expecting an argument. Maybe the intent is call DownTime(totdt) !!!

  5. #5
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    What is DownTime?

    Also, Functions need to have a return value data type specified. Your Function headers should look something like this:
    Code:
    Function MachTime(DC1, DT1, DC2, DT2, DC3, DT3) as Integer
    If the Functions aren't going to return a value, then they should be declared as Subs instead:
    Code:
    Sub MachTime(DC1, DT1, DC2, DT2, DC3, DT3)

  6. #6
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    The problem is that this database has been fine. I have a copy of it in 2007 that I have been working on to get all the bugs out, but have not touch the mdb vesion, so what would cause this now? My production leaders are unable to enter their shift reports, I have to fix this.

  7. #7
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    That, I couldn't tell you. It's possible the database has just become corrupt...

    Edit: I think I've got it figured out. . . Try changing "DownTime" to "MachTime" and see what happens.

  8. #8
    shabyr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    14
    I did change the Downtime to Machtime. I had to comment out a few expression, and now it's working. I pray that all the function still work? Will have to wait and see.
    Thanks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 07-26-2012, 02:06 PM
  2. Replies: 3
    Last Post: 06-09-2012, 08:14 AM
  3. Replies: 3
    Last Post: 05-06-2012, 06:29 PM
  4. Error: The OpenReport action was canceled
    By francisdm@state.gov in forum Reports
    Replies: 1
    Last Post: 12-14-2011, 01:45 PM
  5. Replies: 9
    Last Post: 04-04-2011, 11:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums