My table:
tblHeatTreatment
- HeatTreatmentID - PK
- HeatTreatmentDesc - Text
- HeatTreatmentDetails - Memo
My form has a listbox (lstHeatTreatments - Multi-Select disabled) that displays Heat Treatment descriptions and an unbound textbox (txtHTDetails) that I would like to have display the corresponding memo field when a description is selected from the listbox.
This is my code so far:
When I run the code I get an error:
When I debug, it highlights:
Any ideas?
Thanks in advance
Bruce
tblHeatTreatment
- HeatTreatmentID - PK
- HeatTreatmentDesc - Text
- HeatTreatmentDetails - Memo
My form has a listbox (lstHeatTreatments - Multi-Select disabled) that displays Heat Treatment descriptions and an unbound textbox (txtHTDetails) that I would like to have display the corresponding memo field when a description is selected from the listbox.
This is my code so far:
Code:
Private Sub lstHeatTreatments_AfterUpdate()
Dim myConnection As ADODB.Connection
Dim myRecordSet As New ADODB.Recordset
Dim mySQL As String
Dim selectedRequirementKey As Long
Set myConnection = CurrentProject.AccessConnection
Set myRecordSet.ActiveConnection = myConnection
selectedRequirementKey = Me.lstHeatTreatments.ItemData(Me.lstHeatTreatments.ListIndex)
mySQL = "SELECT HeatTreatmentDetails FROM [tblHeatTreatment] " & _
"WHERE [tblHeatTreatment].[HeatTreatmentID]= " & selectedRequirementKey & " "
MsgBox mySQL
myRecordSet.Open mySQL
Me.txtHTDetails = myRecordSet.Fields
myRecordSet.Close
myConnection.Close
Set myRecordSet = Nothing
Set myConnection = Nothing
End Sub
When I run the code I get an error:
Run-time error '-2147352567 (80020009)':
The Value you entered isn't valid for this field
When I debug, it highlights:
Code:
Me.txtHTDetails = myRecordSet.Fields
Any ideas?
Thanks in advance
Bruce
Last edited: