Connecting Tech Pros Worldwide Help | Site Map

How to get a query to pick up the value of the active form

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 01:29 PM
musicloverlch
Guest
 
Posts: n/a
Default How to get a query to pick up the value of the active form

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


  #2  
Old November 13th, 2005, 01:30 PM
polite person
Guest
 
Posts: n/a
Default Re: How to get a query to pick up the value of the active form

On 7 Sep 2005 18:57:41 -0700, "musicloverlch" <lhowey@gmail.com> wrote:
[color=blue]
>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[/color]

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)

  #3  
Old November 13th, 2005, 01:30 PM
lylefair
Guest
 
Posts: n/a
Default Re: How to get a query to pick up the value of the active form

An idea, but not mine:

Simplicity is the soul of efficiency.

-Austin Freeman
(The Eye of Osiris)

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.