When I try to prepopulate a text field with the result of a query, I get the query string and not the result of the question. How to load the answer in a text box?
********CODE BELOW*************
Private Sub DestinationList_AfterUpdate()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rs As Recordset
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("Temp")
If ((Me.CubicMeters.Value) > 10) Then
strSQL = "SELECT G10 FROM AllCosts WHERE Port ='" & Me.PortDropDown.Value & "' AND Destination = '" & Me.DestinationList.Value & "';"
Else
strSQL = "SELECT L10 FROM AllCosts WHERE Port ='" & Me.PortDropDown.Value & "' AND Destination = '" & Me.DestinationList.Value & "';"
End If
qdf.SQL = strSQL
Set qdf = Nothing
Set db = Nothing
Me.OceanFreightCost.SetFocus
Me.OceanFreightCost.Requery
Me.OceanFreightCost2.Requery
End Sub
********CODE BELOW*************
Private Sub DestinationList_AfterUpdate()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rs As Recordset
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("Temp")
If ((Me.CubicMeters.Value) > 10) Then
strSQL = "SELECT G10 FROM AllCosts WHERE Port ='" & Me.PortDropDown.Value & "' AND Destination = '" & Me.DestinationList.Value & "';"
Else
strSQL = "SELECT L10 FROM AllCosts WHERE Port ='" & Me.PortDropDown.Value & "' AND Destination = '" & Me.DestinationList.Value & "';"
End If
qdf.SQL = strSQL
Set qdf = Nothing
Set db = Nothing
Me.OceanFreightCost.SetFocus
Me.OceanFreightCost.Requery
Me.OceanFreightCost2.Requery
End Sub