C
charles.kendricks
I am trying to assign the values of records in a table to a series of
textboxes. I want to select the particular record by the value of one
field in the table which is tied to a combo box. I used an example
that I got from "VBA For Dummies", but where the example uses a
particular value for the determining field I am trying to use the
current value of the combo box, but it isn't working. The code is:
Private Sub Combo73_BeforeUpdate(Cancel As Integer)
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim rstProgressive As New ADODB.Recordset
rstProgressive.ActiveConnection = cnn1
varValue = Forms![frmPriceMatrix]![Combo73]
Dim strSql As String
strSql = "SELECT tblProgressive.TypeNo,"
strSql = strSql + " tblProgressive.Typename,
tblProgressive.CR39Price,"
strSql = strSql + " tblProgressive.PolycarbPrice,
tblProgressive.Polycarb1Price,"
strSql = strSql + " tblProgressive.PolycarbChildPrice,"
strSql = strSql + " tblProgressive.[156IndexPrice],
tblProgressive.[160IndexPrice],"
strSql = strSql + " tblProgressive.[171IndexPrice],
tblProgressive.GlassPrice"
strSql = strSql + " FROM tblProgressive WHERE
(((tblProgressive.TypeName) = '" & varValue & "'))"
rstProgressive.CursorType = adOpenDynamic
rstProgressive.LockType = adLockOptimistic
rstProgressive.Open strSql
Debug.Print rstProgressive.Fields(3)
End Sub
I'm sure the problem is in the WHERE portion of my SQL
statement....help please
textboxes. I want to select the particular record by the value of one
field in the table which is tied to a combo box. I used an example
that I got from "VBA For Dummies", but where the example uses a
particular value for the determining field I am trying to use the
current value of the combo box, but it isn't working. The code is:
Private Sub Combo73_BeforeUpdate(Cancel As Integer)
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim rstProgressive As New ADODB.Recordset
rstProgressive.ActiveConnection = cnn1
varValue = Forms![frmPriceMatrix]![Combo73]
Dim strSql As String
strSql = "SELECT tblProgressive.TypeNo,"
strSql = strSql + " tblProgressive.Typename,
tblProgressive.CR39Price,"
strSql = strSql + " tblProgressive.PolycarbPrice,
tblProgressive.Polycarb1Price,"
strSql = strSql + " tblProgressive.PolycarbChildPrice,"
strSql = strSql + " tblProgressive.[156IndexPrice],
tblProgressive.[160IndexPrice],"
strSql = strSql + " tblProgressive.[171IndexPrice],
tblProgressive.GlassPrice"
strSql = strSql + " FROM tblProgressive WHERE
(((tblProgressive.TypeName) = '" & varValue & "'))"
rstProgressive.CursorType = adOpenDynamic
rstProgressive.LockType = adLockOptimistic
rstProgressive.Open strSql
Debug.Print rstProgressive.Fields(3)
End Sub
I'm sure the problem is in the WHERE portion of my SQL
statement....help please