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
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