I am trying to update a record, i am not using data control 
Author Message
 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.




Wed, 07 Feb 2001 03:00:00 GMT  
 I am trying to update a record, i am not using data control
First, as soon as you set the database field equal to the contents of the
textbox the database *will* be updated since you are not using
BeginTrans...EndTrans.

You have a couple of options...
(1) Use a transaction and then to a RollBack if the user cancels.
(2) Defer setting the recordset fields to the new data until after the user
has confirmed the change. In other words, use the contents of the textbox
with the old data in the message box when retrieving a user confirmation for
the changed data. Then, if confirmed just perform the update similarly to
what you now do before running the message box.

--
Mark E Alsop



Thu, 08 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. I am trying to update a record, i am not using data control

2. I am trying to create a database application. I am using a data control

3. I am trying to create a database application. I am using a data control

4. I am trying to create a database application. I am using a data control

5. Help - I am getting an error using data control

6. I am trying to connect ot forms using Access 2002

7. I am learning VB.NET and am wondering....

8. When is 5:00 AM not 5:00 AM? When it's 5:00 AM.

9. I am getting duplicate records, I mean everything is duplicate even Access record number

10. ADO Data Control - What Am I Doing Wrong?

11. What am I trying to do?

12. I am trying igain - somebody must know

 

 
Powered by phpBB® Forum Software