Unbound control update data

Jim8541

Registered User.
Local time
Today, 15:52
Joined
Aug 13, 2004
Messages
14
Hi, I'm using an unbound textbox(txtPhone1) to show data(Phone1) on my main form. I populated txtPhone1 using this
Code:
 Me.txtPhone1_SI = Me.cboLastname_SI.Column(4).
Me.cboLastName_SI is a combo box that is based on a query that I use to fill all the data on my main form. My main form doesn't have any bound controls. I was hoping to be able to edit the phone number textbox(txtPhone1) using this
Code:
Dim ioldvalue As Variant
Dim inewvalue As Variant

    ioldvalue = Me![cboPhone1].OldValue
    inewvalue = Me![cboPhone1].Value
        If inewvalue <> ioldvalue Then
            
            CurrentDb.Execute "UPDATE tblEmployee SET [Phone1]=inewvalue"
            End If

But I can't seem to pickup the oldvalue. I tried this in a couple of different events. Do I need to set a global variable to pick up the txtPhone1 value before an event occurs or is there a better way to set this up?
Thanks Jim
 
I use bound controls whenever I can. However, in this instance it wasn't an option so I decided to use this work around. I placed this code in my control's On_Exit event.
Code:
Dim Oldvalue As Variant
Dim Newvalue As Variant
Dim Holder As Integer

Holder = Nz(Me.txtEmpID_SI, 0)
Oldvalue = Me.txtPhone1_Holder
Newvalue = Me.txtPhone1
            If Oldvalue <> Newvalue Then
            CurrentDb.Execute "UPDATE tblemployee SET [Phone1]= '" & Newvalue & "' WHERE [EmployeeID]= " & Holder & ""
            Else
            End If
Holder = ""
 

Users who are viewing this thread

Back
Top Bottom