Passing RecordSource to Form from another form

  • Thread starter Thread starter Doug MacDonald
  • Start date Start date
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
 
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?
 
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
 
Back
Top