Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-19-2017, 09:37 AM   #1
vent
Newly Registered User
 
Join Date: May 2017
Posts: 160
Thanks: 22
Thanked 0 Times in 0 Posts
vent is on a distinguished road
The OpenForm action was canceled

Hi everyone

So i'm working on creating a classic login form. The VBA I wrote did initially work but now suddenly I get this error The OpenForm action was canceled I don't know what happened but if someone could have a look at my VBA and maybe offer some guidance, that would be appreciated. Thank you!



Private Sub btnLogin_Click()

Dim RecSet As Recordset

Set RecSet = CurrentDb.OpenRecordset("tblEmployees", dbOpenSnapshot, dbReadOnly)

RecSet.FindFirst "userName='" & Me.txtUserName & "'"

If RecSet.NoMatch = True Then
Me.lblInvalidUserName.Visible = True
Me.txtUserName.SetFocus
Exit Sub
End If
Me.lblInvalidUserName.Visible = False


If RecSet!Password <> Nz(Me.txtPassWord, """") Then
Me.lblInvalidPassword.Visible = True
Me.txtPassWord.SetFocus
Exit Sub
End If
Me.lblInvalidPassword.Visible = False
DoCmd.OpenForm "frmMain"
DoCmd.Close acForm, Me.Name

End Sub


DoCmd.OpenForm "frmMain"is highlighted yellow and seems to be the problem but I'm confused because it was working previously


Last edited by vent; 05-19-2017 at 09:41 AM. Reason: pinpoint exact error
vent is offline   Reply With Quote
Old 05-19-2017, 09:51 AM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 3,326
Thanks: 0
Thanked 731 Times in 716 Posts
Ranman256 will become famous soon enough Ranman256 will become famous soon enough
Re: The OpenForm action was canceled

DONT use findfirst.

Code:
private btnLogin_click()
sWhere = "[UserName]='" & me.txtUserName & "'"
vName = Dlookup("UserName","tblEmpoyees",sWhere)
vPass = Dlookup("[Password]","tblEmpoyees",sWhere)

'you could have a problem with  case of the text of either the name or pass.

select case true
case IsNull(vName)
    msgbox "Invalid UserID"
   exit sub

case  vName <> me.txtUserName
    msgbox "Invalid UserID"
   exit sub
  
case  vPAss <> me.txtPassword
    msgbox "Invalid Password"
   exit sub
end select 

docmd.openForm "frmMain"
end sub
Ranman256 is offline   Reply With Quote
Old 05-19-2017, 10:03 AM   #3
vent
Newly Registered User
 
Join Date: May 2017
Posts: 160
Thanks: 22
Thanked 0 Times in 0 Posts
vent is on a distinguished road
Re: The OpenForm action was canceled

Thank you for the reply. Unfortunately I changed the VBA and I'm still getting the same error.

vent is offline   Reply With Quote
Old 05-19-2017, 10:11 AM   #4
vent
Newly Registered User
 
Join Date: May 2017
Posts: 160
Thanks: 22
Thanked 0 Times in 0 Posts
vent is on a distinguished road
Re: The OpenForm action was canceled

I just decompiled the databased and now it works fine. Thank you
vent is offline   Reply With Quote
Old 05-23-2017, 11:10 AM   #5
vent
Newly Registered User
 
Join Date: May 2017
Posts: 160
Thanks: 22
Thanked 0 Times in 0 Posts
vent is on a distinguished road
Re: The OpenForm action was canceled

Hello all

So this error still keeps coming up, even though literally a few minutes earlier, the form was working just fine. Why does this keep happening? It is rather frustrating. If anyone has advice thank you!!
vent is offline   Reply With Quote
Old 05-23-2017, 10:09 PM   #6
JHB
Have been here a while
 
Join Date: Jun 2012
Location: In the south of Denmark (Jutland), near the German border.
Posts: 7,668
Thanks: 2
Thanked 2,058 Times in 2,013 Posts
JHB has a spectacular aura about JHB has a spectacular aura about
Re: The OpenForm action was canceled

If it has worked before without problem and you didn't change anything I would suggest creating a new database and import all into it.

__________________
If the above post has helped you, why not take the time to say thank you, by pressing the "Thumbs up."
JHB is offline   Reply With Quote
Reply

Tags
login form , open a form , vba access 2010

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The OpenForm action was canceled gblack Modules & VBA 1 04-04-2015 11:08 AM
The Openform action was canceled...worked OK with mdb not with accdb attman Forms 3 06-26-2013 02:14 AM
The OpenForm action was canceled texas1992 Forms 0 09-06-2012 10:09 AM
The OpenForm action was canceled bingersoll001 Forms 0 03-20-2012 08:36 AM
The Openform Action was canceled cgajendran Forms 4 02-25-2009 05:29 AM




All times are GMT -8. The time now is 08:19 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World