Passing RecordSource to Form from another form

D

Doug MacDonald

I have a form set up with text boxes in the Detail section
and Default view set to Datasheet. It works fine if the
Recordsource is an Access query but I want to use a SQL
statement in VB as the RecordSource. I set the CurrentDB
and Openrecordset with the SQL statement in the Form Load
subroutine. I get no errors but the only record that gets
displayed is the last one. I have a rst.RecordCount in
the code so I know all the records are there.

Do I have to do something to make the Detail section step
to the next record?

Thanks

Doug
 
D

Dirk Goldgar

Doug MacDonald said:
I have a form set up with text boxes in the Detail section
and Default view set to Datasheet. It works fine if the
Recordsource is an Access query but I want to use a SQL
statement in VB as the RecordSource. I set the CurrentDB
and Openrecordset with the SQL statement in the Form Load
subroutine. I get no errors but the only record that gets
displayed is the last one. I have a rst.RecordCount in
the code so I know all the records are there.

Do I have to do something to make the Detail section step
to the next record?

Please post your code. I can't figure out what you're trying to do,
much less what's going wrong with it. Why don't you just set the form's
RecordSource property to your SQL statement in the form's Open event?
 
D

Doug MacDonald

Dirk,

You understood correctly. It was just so simple you
probably thought I meant something more difficult.

Loading the RecordSource with the SELECT statement in the
Open subroutine as you suggested works. I had tried
different things in the Load Subroutine and the Current
Subroutine but didn't try anything in the Open Subroutine.
It turns out loading the RecordSource in the Load
Subroutine also works.

I think I was just going around in circles. I appreciate
you help.

Thanks,

Doug
 

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