jd_boss_hogg
Registered User.
- Local time
- Today, 04:17
- Joined
- Aug 5, 2009
- Messages
- 88
Hi All - i'm a newby to VBA, so please be gentle on me ...
The following code crashes the database at this line in both situations:-
DoCmd.Close acReport, "Month_rp", acSaveNo
i'm trying to close the report." It's a very very basic password check, and the code is assigned to 'on open' of the form.
Any ideas why it actually crashes the whole dbase?
thanks !
The following code crashes the database at this line in both situations:-
DoCmd.Close acReport, "Month_rp", acSaveNo
i'm trying to close the report." It's a very very basic password check, and the code is assigned to 'on open' of the form.
Code:
Private Sub Report_Open(Cancel As Integer)
Dim strPasswd
strPasswd = InputBox("Enter Password", "Restricted Form")
'Check to see if there is any entry made to input box, or if
'cancel button is pressed. If no entry made then exit sub.
If strPasswd = "" Or strPasswd = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
DoCmd.Close acReport, "Month_rp", acSaveNo
Exit Sub
End If
'If correct password is entered open Employees form
'If incorrect password entered give message and exit sub
If strPasswd = "fred" Then
MsgBox "Password Correct!"
Else
MsgBox "Sorry, you do not have access to this report", _
vbOKOnly, "Important Information"
DoCmd.Close acReport, "Month_rp", acSaveNo
Exit Sub
End If
End Sub
thanks !