Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / 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 16:21 GMT
I am very new to using code 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 a
form to retrieve an associated ID within a table that will be used
later. 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

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.
Jan Hyde (VB MVP) - 26 Oct 2007 17:05 GMT
"PaulSchueller@gmail.com" <PaulSchueller@gmail.com>'s wild
thoughts were released on Fri, 26 Oct 2007 15:21:35 -0000
bearing the following fruit:

>I am very new to using code 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 - 16 lines]
>
>This querying technique I have used before, but not with strings and

>I am not sure what the problem is.

Neither do we, you haven't stated what the problem is.

However a combobox doesn't have a value property so either
you're not programming in VB6 (in which case you're in the
wrong group) or that code is not valid.

J

--
Jan Hyde

https://mvp.support.microsoft.com/profile/Jan.Hyde
PaulSchueller@gmail.com - 26 Oct 2007 17:21 GMT
On Oct 26, 12:05 pm, "Jan Hyde (VB MVP)"
<StellaDrin...@REMOVE.ME.uboot.com> wrote:
> "PaulSchuel...@gmail.com" <PaulSchuel...@gmail.com>'s wild
> thoughts were released on Fri, 26 Oct 2007 15:21:35 -0000
[quoted text clipped - 34 lines]
>
> https://mvp.support.microsoft.com/profile/Jan.Hyde

The returned error is Syntax error in from statement, if that is what
you are asking for. I am using VB6.3
Ralph - 26 Oct 2007 17:39 GMT
> On Oct 26, 12:05 pm, "Jan Hyde (VB MVP)"
> <snipped>
[quoted text clipped - 12 lines]
> The returned error is Syntax error in from statement, if that is what
> you are asking for. I am using VB6.3

That's VBA "Visual Basic for Applications".

You should post in a newsgroup for the product container you are using VBA
in. Each of them have designers with different control libraries.

-ralph
Douglas J. Steele - 27 Oct 2007 12:11 GMT
You're missing a space between the closing parenthesis of the WHERE
condition and the key word GROUP.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

>I am very new to using code 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.
 
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



©2009 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.