G
Guest
I am trying to devlop an sql statement that gets the short description from a
table (routes) and updates the forms text field (Notes) with the value
displayed in the lstRoute listbox. I get an error on the docmd.runsql
statement. Also, I am not sure that the Me.Notes statement is correct to
update the Notes field. Would anyone care to help with correcting my problem?
Thank you.
Private Sub LstRoute_Change()
Dim strRteNum As String
strRteNum = Val(Me.LstRoute)
'Displays form to enter a new route
If Me.LstRoute = 1 Then
Me.LstRoute = ""
DoCmd.OpenForm "AddNewRoute", acNormal, , , acFormAdd
End If
If Me.LstRoute > 1 Then
Dim strSQL1st As String, strSQL2nd As String, strSQL3rd As String,
strSQLFull As String
strSQL1st = "SELECT Routes.[Route#], Routes.[Short Description]FROM
Routes"
strSQL2nd = strSQL1st & " WHERE (((Routes.[Route#])=" & strRteNum
strSQL3rd = strSQL2nd & " ));"
Debug.Print strSQL3rd
DoCmd.RunSQL strSQL3rd
'sets note field with short description field of query
Me.Notes = [Short Description]
End If
Me.Recalc
End Sub
table (routes) and updates the forms text field (Notes) with the value
displayed in the lstRoute listbox. I get an error on the docmd.runsql
statement. Also, I am not sure that the Me.Notes statement is correct to
update the Notes field. Would anyone care to help with correcting my problem?
Thank you.
Private Sub LstRoute_Change()
Dim strRteNum As String
strRteNum = Val(Me.LstRoute)
'Displays form to enter a new route
If Me.LstRoute = 1 Then
Me.LstRoute = ""
DoCmd.OpenForm "AddNewRoute", acNormal, , , acFormAdd
End If
If Me.LstRoute > 1 Then
Dim strSQL1st As String, strSQL2nd As String, strSQL3rd As String,
strSQLFull As String
strSQL1st = "SELECT Routes.[Route#], Routes.[Short Description]FROM
Routes"
strSQL2nd = strSQL1st & " WHERE (((Routes.[Route#])=" & strRteNum
strSQL3rd = strSQL2nd & " ));"
Debug.Print strSQL3rd
DoCmd.RunSQL strSQL3rd
'sets note field with short description field of query
Me.Notes = [Short Description]
End If
Me.Recalc
End Sub