Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

SQL and updating text question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wylie C - 19 Nov 2005 15:59 GMT
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
Duane Hookom - 19 Nov 2005 16:08 GMT
It does no good to run your SQL. Also, you are missing a space to the left
of "FROM". Try:

Me.Notes = DLookup("[Short Description]", "Routes","[Route#]=" & strRteNum )

This assumes Rout# is numeric. If it is text:

Me.Notes = DLookup("[Short Description]", "Routes","[Route#]=""" & strRteNum
& """")

I'm not sure why you are storing the short description in more than one
place. I assume you have a good reason for this.

Signature

Duane Hookom
MS Access MVP
--

>I am trying to devlop an sql statement that gets the short description from
>a
[quoted text clipped - 31 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.