vba - Access 2010 Login Form won't close itself -


i have database login form, , upon successful login main navigation form supposed open , login form supposed close... except login form refuses close , instead throws "run-time error '2585': action can't carried out while processing form or report event."

here's i've got code:

private sub buttonlogin_click() dim hash new cmd5 dim salt string dim result string dim rs dao.recordset dim rc dao.recordset set rs = currentdb.openrecordset("tblcurrentuser", dbopendynaset) set rc = currentdb.openrecordset("tblcustom", dbopendynaset) '----check if user id or password null---- if isnull(id)     msgbox "please enter user id", vbokonly     me.id.setfocus     exit sub end if if isnull(password)     msgbox "please enter password", vbokonly     me.password.setfocus     exit sub end if '----validate login information---- ' section builds salted md5 hash , compares ' password stored in personnel table. result = dlookup("password", "tblpersonnel", "empid = '" & id & "'") salt = id & "-" & password if result <> hash.md5(salt)     msgbox "please enter valid user id , password", vbokonly     me.id.setfocus     exit sub end if '----check user access permission---- if dlookup("accesslevel", "tblpersonnel", "empid = '" & id & "'") = 0     msgbox "access denied, please contact " & rc![dba] & " database access.", vbexclamation     me.id.setfocus     exit sub end if '----store current user , access level temp table---- rs.edit rs![userid] = id rs![accesslevel] = dlookup("accesslevel", "tblpersonnel", "empid = '" & id & "'") rs.update rs.close rc.close '----open navigation form, close login---- docmd.openform "frmnavmain", acnormal docmd.close acform, "frmlogin" end sub 

so can see i've got lot going on when user logs in. invalid entries caught , sub exited if happens, assuming checks out, sub rolls down end there , opens nav form , should close itself. debugger points @ docmd.close acform, "frmlogin" line @ bottom every time. i've tried moving line frmnavmain form_onload() still throws same run-time error.

what missing here?

move

docmd.close acform, "frmlogin" 

to onactivate event of frmnavmain. also, check code running in onclose of frmlogin.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -