From: RLN on


I have 4 queries and all 4 queries use different tables and pull
different columns.

Is it possible to have one Generic all Purpose form (frmGeneral) and on
the fly at run time set frmGeneral's data source to any of these
queries:
qry1, qry2, qry3 or qry 4 before showing the form to the user?

Once the form is loaded and in view, can the data source be switched on
the fly if the users elects to see the results of another query? I
tried this but when designing the new form the next step was to drag
fields on to the form. I don't want to do this. I just want to change
data sources on the fly.

My whole reason for this is to cut down on maintenance and only have to
maintain one form instead of four near-duplicate-in-appearance forms.

Thanks.


*** Sent via Developersdex http://www.developersdex.com ***
From: Mark on
You can set the recordsource (any of your queries) in the open event of the
form with:
Select Case DecidingFactorForWhichQuery
Case Factor1 Value
Me.Recordsource = "NameOfQuery1"
Case Factor2 Value
Me.Recordsource = "NameOfQuery2"

etc ....
End Select

Then set the controlsource of controls on your form with:
Select Case DecidingFactorForWhichQuery
Case Factor1 Value
Me!Field1.ControlSource = "NameOfQueryField1"
Me!Field2.ControlSource = "NameOfQueryField2"
Me!Field3.ControlSource = "" ' Does not use field on form
Case Factor2 Value
Me!Field1.ControlSource = "" ' Does not use field on form
Me!Field2.ControlSource = "" ' Does not use field on form
Me!Field3.ControlSource = "NameOfQueryField3"
Me!Field4.ControlSource = "NameOfQueryField4"

etc ....
End Select

Steve


"RLN" <nospamrln(a)devdex.com> wrote in message
news:1215113040_17757(a)news.newsfeeds.com...
>
>
> I have 4 queries and all 4 queries use different tables and pull
> different columns.
>
> Is it possible to have one Generic all Purpose form (frmGeneral) and on
> the fly at run time set frmGeneral's data source to any of these
> queries:
> qry1, qry2, qry3 or qry 4 before showing the form to the user?
>
> Once the form is loaded and in view, can the data source be switched on
> the fly if the users elects to see the results of another query? I
> tried this but when designing the new form the next step was to drag
> fields on to the form. I don't want to do this. I just want to change
> data sources on the fly.
>
> My whole reason for this is to cut down on maintenance and only have to
> maintain one form instead of four near-duplicate-in-appearance forms.
>
> Thanks.
>
>
> *** Sent via Developersdex http://www.developersdex.com ***


From: StopThisAdvertising on

"Mark" <notmy(a)email.com> schreef in bericht news:xLSdnUqUQd1VpvDVnZ2dnUVZ_q_inZ2d(a)earthlink.com...
> You can set the recordsource (any of your queries) in the open event of the
> form with:
> Select Case DecidingFactorForWhichQuery
> Case Factor1 Value
> Me.Recordsource = "NameOfQuery1"
> Case Factor2 Value
> Me.Recordsource = "NameOfQuery2"
>
> etc ....
> End Select
>
> Then set the controlsource of controls on your form with:
> Select Case DecidingFactorForWhichQuery
> Case Factor1 Value
> Me!Field1.ControlSource = "NameOfQueryField1"
> Me!Field2.ControlSource = "NameOfQueryField2"
> Me!Field3.ControlSource = "" ' Does not use field on form
> Case Factor2 Value
> Me!Field1.ControlSource = "" ' Does not use field on form
> Me!Field2.ControlSource = "" ' Does not use field on form
> Me!Field3.ControlSource = "NameOfQueryField3"
> Me!Field4.ControlSource = "NameOfQueryField4"
>
> etc ....
> End Select
>
> Steve
>
>


--
Hey Mark/Steve!! We don't need you here !!
Hey Mark/Steve!! We don't want you here !!

This is to inform 'newbees' here about PCD' Steve:
http://home.tiscali.nl/arracom/whoissteve.html (updated, mainly the 'abuse-reporting' page...)
Until now 5850+ pageloads, 3675+ first-time visitors
(these figures are real and rapidly increasing)

Why is this ???
Because Steve is the ONLY person here who continues to advertise in the groups.

It is not relevant whether he advertised in *this* particular post or not...
==> We want him to know that these groups are *not* his private hunting grounds!

For those who don't like too see all these messages:
==> Simply killfile 'StopThisAdvertising'.
Newbees will still see this warning-message.

ArnoR
From: Linq Adams via AccessMonster.com on
And, of course, if you need to do any type of data validation or manipulation
in the controls' AfterUpdate events or the form's BeforeUpdate event, you'll
have to qualify these as well by identifying which record source is currently
being used.

I've got to tell you, long term, I think you'll find that you're going to
increase your time spent on maintenance, not decrease it.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/200807/1

From: RLN on

Thank you for your code sample here, Mark. I appreciate it.

RLN


*** Sent via Developersdex http://www.developersdex.com ***