How do I change row source on the run?

  • Thread starter Thread starter Niklas Östergren
  • Start date Start date
N

Niklas Östergren

Hi!

I´d like to change a forms row source depending on which cmdButton the user
use!

I have ONE form (frmPerson) which I would like to use with two different
rowsources (qryAllPerson and qryValidMemberShip) depending on which cmd is
pressed (cmdAll and cmdMembers).

I know this may be done but I don´t know how!?

TIA!
// Niklas
 
OK, I´ll try to explain a little bit better what I would like to do!

I would like to open up a form (frmPerson) from another form (ex.
frmOpenFormTest) with help of 2 command buttons (cmdAllPerson OR
cmdMembers). I´d like to change the record source for form frmPerson
depending on which cmd is used!

I do understand that I have to change the record source of ´form frmPerson
but I don´t know HOW from another form since form frmPerson isn´t open
before the click event for resp. cmd is fired!

TIA!

// Niklas
 
In the sub that opens the forms you could do first declare
dim openForm as frmPerson

Now openForm is an object of type frmPerson. You need to create an instance

Set openForm = New frmPerson

openForm.rowsource = ....

While myform.Count = myform.Count
i = DoEvents()
Wend

This is a real quick and dirty way.. there is a neater way but I can't
remember it just now. :) so you have to handle the error that comes up when
the form is closed
by ignoring it
 
Thank´s a lot for ypu reply!

I didn´t realy get it but you made mee think a little bit so I came up with
another solution instead.

I created a public variable "booRowSourceValidMemberShip" which I then set
to True/False in the click event of the cmd´s depending on which Q I want as
a row source.

I then check this variable with a simpel If ... Then in the open event off
the form "frmPerson" and set the recordsource with "Me.Recordsource = ..."
With this way I don´t have any error´s when I close the form!

Thank´s for letting me use my own brain for once ;-)


Maby ther´s a better/easyer way. If so please let me know!

// Niklas
 
Back
Top