Hello all,
What im trying to do is create a form that can update and save over a record that already exisits in the table it is saving to.
So far I have it so the form will detect a record that is already there and prompts the user to let them know that there is a record but what i want to do is after that prompt the user again and ask if they wish to overwrite the record that is already there?
So to give a little more detail I have 3 fields on my form Name, errCodeNum, errCodeReason. So i want to make it that if name and errCodeNum are already in there but the reason is different it will find the original record and then save over it.
Here is what i have so far i know the problem is the With statement just not sure how to get it to work right??
Appreciate any help with this!
What im trying to do is create a form that can update and save over a record that already exisits in the table it is saving to.
So far I have it so the form will detect a record that is already there and prompts the user to let them know that there is a record but what i want to do is after that prompt the user again and ask if they wish to overwrite the record that is already there?
So to give a little more detail I have 3 fields on my form Name, errCodeNum, errCodeReason. So i want to make it that if name and errCodeNum are already in there but the reason is different it will find the original record and then save over it.
Here is what i have so far i know the problem is the With statement just not sure how to get it to work right??
Appreciate any help with this!
Code:
Dim Db As DAO.Recordset
Dim rst As DAO.Database
Dim LResponse as string
If DCount("*", _
"[Table]", _
"(([Name]=" & Chr(34) & Me.Combo0 & Chr(34) & ") AND (" & _
"[errCodeNum]=" & Chr(34) & Me.Combo2 & Chr(34) & "))") > 0 Then
Call MsgBox("This record already exists.", vbExclamation)
LResponse = MsgBox("Would you like to overwrite this record?", vbYesNo, "Overwrite")
If LResponse = vbNo Then
Cancel = True
Else
with Current.Db
[Name]= Combo0
[errCodeNum] = combo2
[errCodeReason] = text1
Db.update
end with
End If
End If
Comment