Query data to Form ?

NoFrills

Registered User.
Local time
Yesterday, 20:20
Joined
Oct 14, 2004
Messages
35
I did a search and looked around, but not sure how it would be worded. Nothing I read thus far helped.

I am sure this is so basic and simple, I just can't figure it out.

I am trying to grab the data from a query and have it inserted into a subform of mine. The query has 3 fields: 2 fields being used as group by, and a 3rd as a count.

Field1 - Field2 - Field3
Bobby Red 5
Bobby Blue 2
Tim Red 3
Tim Grey 1
...
...

So its grouped by Field1, Then by Field2, and calculates how many time it happens in field3.

I want field3 to be used in a textbox which has a control source on my subform. But how do I get that value into the form?

I do not know how to make a form see the fields of a query. Is it a rs, db, qdf code? a Docmd code?

Any help will be appreciated.
 
OK I read read somewhere that access 2000 and newer version automatically default

Dim rs as recordset

as an ADO type, which was given me an error message on invalid type. So I changed it too

Dim rs DAO.Recordset.

So I now can play around with the query fields at will. Thanks for your time in answering. Why is it you almost always uncover your answer after you post it. weird. The final block which works for me. I am happy.

Code:
Code
Private Sub Combo80_AfterUpdate()
Dim rs As DAO.Recordset
Dim db As Database
Dim a, b, c, d, e, f


Set db = CurrentDb
Set rs = db.OpenRecordset("SAEquery")

rs.MoveFirst

a = rs.RecordCount
d = Combo80.Value
e = ProtocolNumber4.Value

For i = 1 To a - 1
b = rs.Fields(1)
c = rs.Fields(2)

If (b = d) And (c = e) Then
                            f = rs.Fields(0)
                            Text87.SetFocus
                            Text87.Value = f
                            End If
rs.MoveNext
 
Next

rs.Close

End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom