I'm at wits end here. Commands that seem to work in forms do not appear to work in Functions, and the logic doesnt appear to be working. Current version is ACC97, but going to ACC-XP shortly, so I'd like code that works in both.
I have a function called ValidUser that determines if the user should or should not be in the database. If not, the user has the option to send an email to the admin (me) to add the user. There lies the problem. Code below. I'll skip what brings us to this point as that part works.
[tt]
NotAValidUser:
Notify = MsgBox("You are currently not listed as a user in the " & TheDB & " database" & vbCrLf & _
"Do you wish to notify the Database Admin?", vbYesNo)
If Notify = vbYes Then
DoCmd.SendObject , , , "admin1", "admin2", , "Please add me as a user to the " & TheDB & " Database", , True
MsgBox "Thank you. You will be notified when you are added as a user", vbOKOnly
DoCmd.Quit
Else
DoCmd.Quit
End If
Exit Function [/tt]
It asks me if I want to notify the admin, I click on No and it goes back to the form continuing like it was a valid user. If I click on yes, it shoots off the email, gives the thank you and continues along.
instead of DoCmd.Quit I've tried RunCommand acCmdExit which seems to work just as well and application.quit which works just as well and application.exit closes the DB, but leaves Access open and you cant do anything with it.
What is the way to close a database from a function?
I have a function called ValidUser that determines if the user should or should not be in the database. If not, the user has the option to send an email to the admin (me) to add the user. There lies the problem. Code below. I'll skip what brings us to this point as that part works.
[tt]
NotAValidUser:
Notify = MsgBox("You are currently not listed as a user in the " & TheDB & " database" & vbCrLf & _
"Do you wish to notify the Database Admin?", vbYesNo)
If Notify = vbYes Then
DoCmd.SendObject , , , "admin1", "admin2", , "Please add me as a user to the " & TheDB & " Database", , True
MsgBox "Thank you. You will be notified when you are added as a user", vbOKOnly
DoCmd.Quit
Else
DoCmd.Quit
End If
Exit Function [/tt]
It asks me if I want to notify the admin, I click on No and it goes back to the form continuing like it was a valid user. If I click on yes, it shoots off the email, gives the thank you and continues along.
instead of DoCmd.Quit I've tried RunCommand acCmdExit which seems to work just as well and application.quit which works just as well and application.exit closes the DB, but leaves Access open and you cant do anything with it.
What is the way to close a database from a function?