I am trying to update a record, i am not using data control
HELLO
I am trying to update a record after doing search and displaying a record
from a query.
The following code updates the second record while I am updating the first
record. I am looking for a update code witch allows me to update and view
the old record and updated one then I click on update if I want to update
and cancel if I do not.
Dim Data As Database
Dim Customers As Recordset
Dim StrOldFirst As String
Dim StrOldLast As String
Dim strMessage As String
Set Data = OpenDatabase("C:\kingVideo\king.mdb")
Set Customers = Data.OpenRecordset("Customer")
With Customers
txtCustomerNo = Customers!CustomerNo
Customers.MovePrevious
.Edit
' Store original data.
StrOldFirst = !CustomerFirstName
StrOldLast = !CustomerLastName
' Change data in edit buffer.
!CustomerFirstName = txtFirstName
!CustomerLastName = txtLastName
' Show contents of buffer and get user input.
strMessage = "Edit in progress:" & vbCr & _
" Original data = " & StrOldFirst & " " & _
StrOldLast & vbCr & " Data in buffer = " & _
!CustomerFirstName & " " & !CustomerLastName & vbCr & vbCr & _
"Use Update to replace the original data with " & _
"the buffered data in the Recordset?"
If MsgBox(strMessage, vbYesNo, "Update NOW!!! ") = vbYes Then
.Update
Else
.CancelUpdate
MsgBox "Update was Canceld"
End If
' Show the resulting data.
MsgBox "Data in recordset = " & !CustomerFirstName & " " & _
!CustomerLastName
' Restore original data because this is a demonstration.
If Not (StrOldFirst = !CustomerFirstName And _
StrOldLast = !CustomerLastName) Then
.Edit
!CustomerFirstName = StrOldFirst
!CustomerLastName = StrOldLast
.Update
End If
.Close
End With
The following code updates the second record while I am updating the first
record. I am looking for a update code witch allows me to update and view
the old record and updated one then I click on update if I want to update
and cancel if I do not.