문제

Public Function EditUpdate()
Dim rstEditAddress As DAO.Recordset
Dim Svalue, EditedAddressLine1 As Variant

Svalue = Me.lstBoxCompanyName.Value

EditAddressValue = "SELECT * FROM Companies WHERE CompanyID =  " & Svalue
Set rstEditAddress = CurrentDb.OpenRecordset(EditAddressValue)

EditedAddressLine1 = Me.txtbxAddressLine1.Value

With rstEditAddress
 .Edit
    .Fields("AddressLine1") = EditedAddressLine1
    .Fields("AddressLine2") = NewAddressLine2
    .Fields("AddressLine3") = NewAddressLine3
    .Fields("Town") = NewTown
 .Update
End With

End Function

I have a text box conveniently named txtbxAddressLine1. Using the On Change event in Access, the event calls this function and should go through the procedure of updating the record in the table with the 'edited' data. However the value in EditedAddressLine1 never seems to change! It always has the value of which was originally in the table.

Any suggestions as to why this is happening?

도움이 되었습니까?

해결책

In a Change event handler for a control, read its Text not Value property to get the new data:

EditedAddressLine1 = Me.txtbxAddressLine1.Text
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top