Update and Insert in a SAVE button (Urgent! thx!)

smallWorld

Registered User.
Local time
Tomorrow, 05:13
Joined
Jan 10, 2008
Messages
15
When user click on SAVE button, it will check if there are any existing EmployeeID. If yes, update the gender and address fields. If not, insert as a new record.
 

Attachments

Is there a question here somewhere?

I haven't looked at your d/b (don't have time). But use the DCOUNT function to how many of the given employeeID. If DCOUNT returns 0 then create a new record. Otherwise run an update query.

hth
Chris
 
Should be something like this

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim FLD As DAO.Field

Set rst = CurrentDb.OpenRecordset("Select * From Product_Master " & _
"where productcode=" & ProductCode)
If rst.EOF And rst.BOF Then
rst.AddNew
Else
rst.Edit
End If
For Each FLD In rst.Fields
rst(FLD.Name) = Me(FLD.Name)
Next FLD
rst.Update
rst.Close
Set rst = Nothing

HTH
 

Users who are viewing this thread

Back
Top Bottom