Assigning recorset values using Combo Box

  • Thread starter charles.kendricks
  • Start date
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top