On 7 Sep 2005 18:57:41 -0700, "musicloverlch" <lh****@gmail.com> wrote:
Here is the situation: I have a main form with lots of tabs. The
first tab has a subform with a lot of tabs.
Each of those tabs has 1 subform. That subform contains an ID. So
subsubform1 has an ID, subsubform2 has an ID up thru subsubform40. The
ID on every subform is named exactly the same thing: intID.
I need to put a button on each subsubform. That button opens another
form based on the intID of that particular subsubform.
I would prefer to have one form open up from the subsubform. Do I
change the recordsource of the new form each time I open it? Is there
a way I could write the query to recognize the ID of whatever
subsubform the user is on?
Any ideas?
Thanks in advance,
Laura
Hi
In the onclick event of the button on each subform, open your "one form"
using the openargs argument to pass the value of intID:
DoCmd.OpenForm formname,,,,,,IntID
then in the Open event of the form set the recordsource, eg
Private Sub Form_Open(Cancel As Integer)
dim sql$, intID&
intID = me.Openargs 'note this is actually a string
....code to set sql depending on the value of intID
Me.Recordsource = sql
End Sub
Alternatively if you can express all the recordsources you need as just one query
which uses the value of IntID as a parameter, you could store the value of the
local intID in some public variable in a standard module as part of the button click event,
and use that value in the sql of recordsouce via a public function.
(Or even use the official parameter mechanism,if you understand how to do it)