Alternate to DLOOKUP for unbound form controls
Posted on 2009-03-29
I need a quick answer to something I have been trying to solve for the past three hours. I have a continuous form that displays a lot of records from a calculated query. I Need to have some controls in the form footer for calculated totals. The totals have to come form a query called QRY_MILEAGEMATRIX_FORMTOTALS. I am currently using unbound controls with the following
txtbox1 = Dlookup.........
txtBox2 = Dlookup.........
and so on. As we all know that Dlookup takes too long. I am trying to populate these controls using a vb select statement but cannot figure it out. I have tried the following two solutions to no avail
Dim rs As Recordset
rs.OpenRecordset "Select * From QRY_MILEAGEMATRIX_FORMTOTALS"
Me.TOT_MILES = rs("TOT_MILES")
Me.BASE_DOL_P_MILE = rs("BASE_DOL_P_MILE")
Dim strSQL As String
strSQL = "Select [TOT_MILES],[BASE_DOL_P_MILE] from QRY_MILEAGEMATRIX_FORMTOTALS;"
Me.TOT_MILES = ("TOT_MILES")
Me.BASE_DOL_P_MILE = ("BASE_DOL_P_MILE")
Your valuable knowledge is appreciated!!