code to include a password?

  • Thread starter Thread starter jo
  • Start date Start date
J

jo

Hi i need some code to add to code I already have that can automactically
enter the password so that i can create reports that is schudeled on a weekly
basis: This is my code that i have when I did not have a password on the form:
'------------------------------------------------------------
' checker_Query_overdue
'
'------------------------------------------------------------
Function checker_Query_overdue()
On Error GoTo checker_Query_overdue_Err

If (DCount("*", "OnOpenOverdue") > 0) Then
DoCmd.OpenReport "OnOpenOverdue", acPreview
DoCmd.OutputTo _
acOutputReport, , acFormatSNP, _
Application.CurrentProject.Path & "\Overdue.snp", False
DoCmd.Close acReport, "OnOpenOverdue", acSaveNo

Call SendNotesMail("Gauge Control", _
Application.CurrentProject.Path & "\Overdue.snp", _
"StandardRoomGuys", "Gauges Overdue", False)
DoCmd.Close acReport, "Overdue.snp", acSaveNo

Else
Exit Function
End If
Application.Quit

checker_Query_overdue_Exit:
Exit Function

checker_Query_overdue_Err:
MsgBox Error$
Resume checker_Query_overdue_Exit

End Function
 
What kind of password? (e.g. Access, SQL Server, other)
How do you normally enter this password?
How did you password the form?
 
Hi thanks for the reply, this is how the program first worked:
I have a schedule task once a week that opens the access program then the
code would then create a report, then email the report to users, all works
good. Then the user ask for a password on the switchboard to prevent other
non authorised users to alter records. And it is after I added a password on
the button on the switchboard that I can no longer run this code so i assume
its the Password form causing the problem. So I thought I might need a piece
of code that would automatically the password in???
thanks jo
 
How did you add the password? Is it an Access User Level password, or
something you implemented with VBA code?
 
Hi the password is in access that is a form with an unbound box with:
Input Mask=Password
Validation Rule= "SecretWord"
Validation Text= Invalid Password try again
Then an OK Button with a Event to run Macro and password is correct will
open the form required.
Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

Dim stDocName As String

stDocName = "Add I/R tols"
DoCmd.RunMacro stDocName

Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click

End Sub

Option Compare Database

'------------------------------------------------------------
' Add_I_R_tols
'
'------------------------------------------------------------
Function Add_I_R_tols()
On Error GoTo Add_I_R_tols_Err

If (Forms!Form1!Text0 = "D11") Then
DoCmd.OpenForm "Tolerances", acNormal, "", "", acAdd, acNormal
End If
DoCmd.Close acForm, "Form1"


Add_I_R_tols_Exit:
Exit Function

Add_I_R_tols_Err:
MsgBox Error$
Resume Add_I_R_tols_Exit

End Function

And a Cancel button that closes the Password dialog.
Private Sub DIALOG_CLOSE_Click()
On Error GoTo Err_DIALOG_CLOSE_Click


DoCmd.Close

Exit_DIALOG_CLOSE_Click:
Exit Sub

Err_DIALOG_CLOSE_Click:
MsgBox Err.Description
Resume Exit_DIALOG_CLOSE_Click

End Sub
 
Hi, sorry I have since found that the problem was with my Scheduled Task I
think due to the fact we had to renew our password and so the password on the
scheduled task would not have been correct as I did not think to change the
password on the scheduled Tasks.
Thanks for you help
Jo
 
Back
Top