質問

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