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 / October 2007

Tip: Looking for answers? Try searching our database.

Error in query referring to Combo Box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PaulSchueller@gmail.com - 26 Oct 2007 17:28 GMT
I am very new to using VBA to build forms and am having a problem.  I
trying to embed a query within a public sub routine.  The goal of this
query is to use an alphanumeric code entered into a combo box on the
form to retrieve an associated ID within a table. The bound column of
the combo box is text. I have used the following code:

Public Sub GetSturID(intSturID As Integer)
Dim rsSturID As ADODB.Recordset
Set rsSturID = New ADODB.Recordset
  rsSturID.Open "SELECT tblSturg.SturgID FROM tblSturg WHERE
(tblSturg.PIT = '" & cmbPIT.Value & "')" _
      & "GROUP BY tblSturg.SturgID", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic, adCmdTable
  rsSturID.MoveFirst
  intSturID = rsSturID("SturgID")
  rsSturID.Close
End Sub

Error Reads: Syntax error in FROM Clause.  This querying technique I
have used before, but not with strings and I
am not sure what the problem is. I have tried many things, but to no
avail.  Your help is much appreciated.
ruralguy - 26 Oct 2007 19:23 GMT
Put your SELECT string in a String variable and then show it in a MsgBox
before you use it.  You probably have places where an extra space in the
string would help.

>I am very new to using VBA to build forms and am having a problem.  I
>trying to embed a query within a public sub routine.  The goal of this
[quoted text clipped - 18 lines]
>am not sure what the problem is. I have tried many things, but to no
>avail.  Your help is much appreciated.

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

PaulSchueller@gmail.com - 27 Oct 2007 15:07 GMT
On Oct 26, 2:23 pm, "ruralguy via AccessMonster.com" <u12102@uwe>
wrote:
> Put your SELECT string in a String variable and then show it in a MsgBox
> before you use it.  You probably have places where an extra space in the
[quoted text clipped - 29 lines]
>
> Message posted viahttp://www.accessmonster.com

It ended up being that the adCmdTable at the end of the select
statement was not needed.
Thanks
ruralguy - 27 Oct 2007 15:46 GMT
Thanks for posting back with your success.

>On Oct 26, 2:23 pm, "ruralguy via AccessMonster.com" <u12102@uwe>
>wrote:
[quoted text clipped - 7 lines]
>statement was not needed.
>Thanks

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

 
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.