Trying to add records to a subform based upon selection in a combo box on the main form

J

Jasonm

Hi all (again),

I am trying to add records to the subform based upon a selection in the
mainform. I am using the following code to try and get to the records that I
want:

Dim rs As DAO.Recordset ' declare a variable for the recordet
Dim db As DAO.Database ' declare a variable for the database
Dim strSQL As String ' declare a variable for the sql string
Dim intCount As Integer



Set db = CurrentDb ' set the db to the current database
Set rs = db.OpenRecordset("tblConstituent", dbOpenDynaset)
intCount = rs.RecordCount ' use this to count records retrieved

I am not getting any errors with any of the above code, but the number of
records recieved is only 1 and there are probably 12 in the actual table I
am trying to get to.

I have also tried the following:
Set rs = db.OpenRecordset("SELECT * FROM tblConstituent", dbOpenDynaset)

I am getting the correct field names when I step through the code, but still
no records...
Is there something wrong with the above code? Any help would be appreciated.
Jasonm
 
J

Jasonm

Please ignore this post, I figured out that everything was working as it
should have only I hadn't really understood the recordcount property... I
was getting all of the records that I needed. Now on to the next task:
Getting all those records into the subform datatable!

Have a great holiday weekend everyone!

Jasonm
 
J

John Vinson

Now on to the next task:
Getting all those records into the subform datatable!

Have you deliberately chosen to reinvent the wheel?

If you use a bound subform, using the datatable as the Subform's
Recordsource and the appropriate master/child link field, you need NO
CODE AT ALL - Access does it all for you.

Of course maybe you *have* done this intentionally; if so please
explain why, and what problems you're having.

John W. Vinson[MVP]
 

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