P
PaulSchueller
I am very new to using VBA to build forms and am having a problem. I
have posted in many groups looking for an answer. I am 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
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.
have posted in many groups looking for an answer. I am 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
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.