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.
"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
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.