The code works ok.............but

G

Guest

This code works ok, but I need to filter it down to the user who opens this
form up. Just where do run the filter or........

Option Compare Database ' SYSTEM ENTRY FORM MODULE
Dim db As Database
Dim r As Recordset
Option Explicit

Private Sub Command18_Click()
' this is just a response to the cancel button
' you can also close the form or database if you wish
MsgBox "you have clicked the cancel button"
DoCmd.CancelEvent
End Sub

' this routine is part of a biiger routine belonging to a database entry one
' you will need to name the variables and table reference accotdingly
' the code below is run if the continue button is pressed
Private Sub Command8_Click()
On Error GoTo errorfix
' this line sets the databse to the current one open
Set db = CurrentDb
' this line sets the record set
Set r = db.OpenRecordset("personal1")
' this code moves to the first record inthe table
r.MoveFirst
' this line starts the loop to find a matching record
Do Until r.EOF
' this line checks the current record to see if it matches the data
entered
If pass1 = r![pasword one] And name1 = r![service number] Then
MsgBox "this message is appearing instead of the code to open the
next form"
' the next line is where you will name the form you want to open
'DoCmd.OpenForm ("form name here")
' this line closes the form after a successful name and password are
entered
DoCmd.OpenReport ("RptIndividual Training Report"), (acViewPreview)
GoTo exit_sub
Else
' if the current record doesnt match this line moves to the next record
r.MoveNext
End If
' loop trhough all the records looking for a match
Loop

' if the user enters the wrong details the following message appears

MsgBox "THE PASSWORD,THE WATCH OR USER NAME DO NOT MATCH.THE DATABASE WILL
NOW CLOSE"
' the next line would normally close the databse but for now its rem'd
'just the form will close instead
'DoCmd.quit
DoCmd.Close acForm, ("systementry")

exit_sub:
Exit Sub

errorfix:
MsgBox Err.Description
Resume exit_sub

End Sub

Private Sub Command21_Click()
On Error GoTo Err_Command21_Click


Screen.PreviousControl.SetFocus
DoCmd.FindNext

Exit_Command21_Click:
Exit Sub

Err_Command21_Click:
MsgBox Err.Description
Resume Exit_Command21_Click

End Sub
 
G

Guest

Rob

I just tried to do the same thing, and all it did was send me back to the
form.

I guess if there is way, nothing is secure. But thanks for the input

Rob Oldfield said:
Attempting to code security in that way doesn't work. I can hold down the
shift key while clicking Open and BANG... you have no security.

Look at http://support.microsoft.com/support/access/content/secfaq.asp


Joe8915 said:
This code works ok, but I need to filter it down to the user who opens this
form up. Just where do run the filter or........

Option Compare Database ' SYSTEM ENTRY FORM MODULE
Dim db As Database
Dim r As Recordset
Option Explicit

Private Sub Command18_Click()
' this is just a response to the cancel button
' you can also close the form or database if you wish
MsgBox "you have clicked the cancel button"
DoCmd.CancelEvent
End Sub

' this routine is part of a biiger routine belonging to a database entry one
' you will need to name the variables and table reference accotdingly
' the code below is run if the continue button is pressed
Private Sub Command8_Click()
On Error GoTo errorfix
' this line sets the databse to the current one open
Set db = CurrentDb
' this line sets the record set
Set r = db.OpenRecordset("personal1")
' this code moves to the first record inthe table
r.MoveFirst
' this line starts the loop to find a matching record
Do Until r.EOF
' this line checks the current record to see if it matches the data
entered
If pass1 = r![pasword one] And name1 = r![service number] Then
MsgBox "this message is appearing instead of the code to open the
next form"
' the next line is where you will name the form you want to open
'DoCmd.OpenForm ("form name here")
' this line closes the form after a successful name and password are
entered
DoCmd.OpenReport ("RptIndividual Training Report"), (acViewPreview)
GoTo exit_sub
Else
' if the current record doesnt match this line moves to the next record
r.MoveNext
End If
' loop trhough all the records looking for a match
Loop

' if the user enters the wrong details the following message appears

MsgBox "THE PASSWORD,THE WATCH OR USER NAME DO NOT MATCH.THE DATABASE WILL
NOW CLOSE"
' the next line would normally close the databse but for now its rem'd
'just the form will close instead
'DoCmd.quit
DoCmd.Close acForm, ("systementry")

exit_sub:
Exit Sub

errorfix:
MsgBox Err.Description
Resume exit_sub

End Sub

Private Sub Command21_Click()
On Error GoTo Err_Command21_Click


Screen.PreviousControl.SetFocus
DoCmd.FindNext

Exit_Command21_Click:
Exit Sub

Err_Command21_Click:
MsgBox Err.Description
Resume Exit_Command21_Click

End Sub
 
R

Rob Oldfield

That's opening the db, not the form itself.


Joe8915 said:
Rob

I just tried to do the same thing, and all it did was send me back to the
form.

I guess if there is way, nothing is secure. But thanks for the input

Rob Oldfield said:
Attempting to code security in that way doesn't work. I can hold down the
shift key while clicking Open and BANG... you have no security.

Look at http://support.microsoft.com/support/access/content/secfaq.asp


Joe8915 said:
This code works ok, but I need to filter it down to the user who opens this
form up. Just where do run the filter or........

Option Compare Database ' SYSTEM ENTRY FORM MODULE
Dim db As Database
Dim r As Recordset
Option Explicit

Private Sub Command18_Click()
' this is just a response to the cancel button
' you can also close the form or database if you wish
MsgBox "you have clicked the cancel button"
DoCmd.CancelEvent
End Sub

' this routine is part of a biiger routine belonging to a database
entry
one
' you will need to name the variables and table reference accotdingly
' the code below is run if the continue button is pressed
Private Sub Command8_Click()
On Error GoTo errorfix
' this line sets the databse to the current one open
Set db = CurrentDb
' this line sets the record set
Set r = db.OpenRecordset("personal1")
' this code moves to the first record inthe table
r.MoveFirst
' this line starts the loop to find a matching record
Do Until r.EOF
' this line checks the current record to see if it matches the data
entered
If pass1 = r![pasword one] And name1 = r![service number] Then
MsgBox "this message is appearing instead of the code to open the
next form"
' the next line is where you will name the form you want to open
'DoCmd.OpenForm ("form name here")
' this line closes the form after a successful name and
password
are
entered
DoCmd.OpenReport ("RptIndividual Training Report"), (acViewPreview)
GoTo exit_sub
Else
' if the current record doesnt match this line moves to the next record
r.MoveNext
End If
' loop trhough all the records looking for a match
Loop

' if the user enters the wrong details the following message appears

MsgBox "THE PASSWORD,THE WATCH OR USER NAME DO NOT MATCH.THE DATABASE WILL
NOW CLOSE"
' the next line would normally close the databse but for now its rem'd
'just the form will close instead
'DoCmd.quit
DoCmd.Close acForm, ("systementry")

exit_sub:
Exit Sub

errorfix:
MsgBox Err.Description
Resume exit_sub

End Sub

Private Sub Command21_Click()
On Error GoTo Err_Command21_Click


Screen.PreviousControl.SetFocus
DoCmd.FindNext

Exit_Command21_Click:
Exit Sub

Err_Command21_Click:
MsgBox Err.Description
Resume Exit_Command21_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top