OK I am a newbie, I am learning as I go and I more the most part I have been able to find my answers on the net within 2 to 3 hours. This one is stumping me.
I have time card form that when I have an employee that wants to log an event a form that I created called PINForm pops up and asks for their pin prior to performing the action that the button on the TimeCardForm is designed to do. The problem I am having is that the data entered into the PINForm only updates the first record in the Employees table. I have a combo bod that I use for the employee to find their record first, but the data still gets entered into the first record of the Employees talble no matter who is selected from the combo box on the TimeCardForm. Here is my code so far.
Whats the idea: In my head I have the program checking the pin number against a preset pin number in the "Employees" table. The TimeCardForm has its Record Source as the "Emloyees" table. The PINForm has it's Record Source as the "Employees" table as well.
This is where the form is called from to check the PIN number (right now since I am in testing phase I am not allowing it to complete it's function)
- From the TimeCardForm -
Private Sub StartNew_Click()
Dim dbs As Database
Dim UserName As String
Dim EmpID As Long
Dim CurDate As Date
Dim PIN As String
Dim PauseTime As Variant
Dim start As Variant
Set dbs = CurrentDb
' A value of 1 indicates that a time card has been initiated
If ([TimeCardStarted] = "1") Then
' Checks to see if the time card is for todays date
If ([TimeCardDate] = Date) Then
' When there is a time card started tells the employee what to do
MsgBox "You have already started a Time-Card for today!", , "Please Check Your Selection and Try Again"
' Prevents the sub from adding a new time card
GoTo Exists
Else: MsgBox "You Failed to Log-Out on your last work day!" & vbCrLf & "Please see the Office Manager" & vbCrLf & "Or you may not receive proper pay for the day!", , "See The Office Manager!"
GoTo AddTimeCard:
End If
End If
If ([TimeCardStarted] = "2") Then
GoTo AddTimeCard
End If
' Not sure why but this is the only place this works when an employee has not selected who they are from the combo box
MsgBox "Please select your Employee Number first", , "EMPLOYEE NUMBER REQUIRED"
GoTo Exists
AddTimeCard:
DoCmd.OpenForm "PINForm", acNormal, "", "", , acNormal
' Needed time for the data to be recognised
PauseTime = 7
start = Timer
Do While Timer < start + PauseTime
DoEvents
Loop
' Not sure if needed but couldn't hurt
Me.Refresh
If [PINNumber] = [PINCheck] Then MsgBox "it did work" ----- Error checking here
' trying to reset the data entered from the PINform to something other than their actual pin number
[PINCheck] = "9999"
' this goto gets deleted once I figure out the problem
GoTo Exists
DoCmd.Hourglass True
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO EmpTimeCardsTbl(EmpID,UserName,InForTheDay,CurDate ,EmpLast,EmpFirst)VALUES (EmpID,UserName, Now(),date(),LastName,FirstName);"
DoCmd.Hourglass False
DoCmd.SetWarnings True
Me.TimeCardStarted = "1"
[TimeCardDate] = Date
Me.Refresh
Exists:
End Sub
This is what I have from the PINForm
Option Compare Database
Private Sub Text0_AfterUpdate()
Me.Refresh
DoCmd.Close
End Sub
Any ideas? I had been working with Dlookup for a while and was so F'n confused that I went a different route.
I am sure it probably something in the book on page 1291 that I have not gotten to yet, but hey if you have a moment and you do not mind giving me some advice - great.