Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a record that was previously inputed. *please help*

Status
Not open for further replies.

mx3gsr

Technical User
Jan 30, 2002
2
US
Hi all,

I'm very new to access and i'm wondering if there is someone kind enough to help me out.

here's the situation,

i'm setting up a database to track personnel timecards.

Employee enters in information daily, the next day, the employee forgets that he/she inputed a timecard entry for the day before and tries to input yesterday's date and employee name into the form.

Is there a way that access knows that there is an existing record for that date/employee and automatically inputs what the employee inputed yesterday into the form?

please help.

thanks in advance
 
mx,
If you make the fields for EmployeeID and date (...not sure what you've actually named them but you get the picture) the Primary Key, then the user won't be able to enter the record twice. Now, to go to that record that is already there, do the following:

In the Forms Error Event:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim rst As Recordset
If DataErr = 3022 Then
Set rst = Me.RecordsetClone
rst.FindFirst "EmployeeID = " & Me.EmployeeID & " AND EmpDate = #" & me.EmpDate & "#"
If rst.NoMatch Then
'big problem
Else
Response = acDataErrContinue 'suppress standard error message
Me.Undo 'undo the 'bad' record
'you could put a message box here telling the user what's going on, or just let him figure it out.
Me.Bookmark = rst.Bookmark
End If
End If

End Sub

Change fieldnames accordingly, and if EmployeeID is a String, you need to put single quotes next to the double quotes in the Findfirst:
rst.FindFirst "EmployeeID = '" & Me.EmployeeID & "' AND EmpDat....

--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top