I need to modify the following code to allow me to specify which records to display in each of several text boxes on my report.
Dim rs As DAO.Recordset
Dim strValues As String
Set rs=CurrentDB.Openrecordset
("MyQuery"
)
rs.MoveFirst
Do Until es.eof
strValues=rs("My Field") & "," & strValues
rs.MoveNext
Loop
Me.mycontrol= Left(strValues, Len(strValues)-1)
Set rs= nothing
This works great but it populates mycontrol with all the values from the appropriate field in the query. I have several controls on my report representing States :
me.mycontrolCA
me.mycontrolFL
me.mycontrolTX
I need a way to specify :
Me.mycontrolCA= Left(strValues, Len(strValues)-1) WHERE MyQuery.State=CA
Me.mycontrolCA= Left(strValues, Len(strValues)-1) WHERE MyQuery.State=FL
Me.mycontrolCA= Left(strValues, Len(strValues)-1) WHERE MyQuery.State=TX
Start Free Trial