Storing subform name in variable when clicked 
Author Message
 Storing subform name in variable when clicked

I have a main form with a tabbed control that contains a datasheet
subform on each tab.

I want to be able to click in one of the subforms (datasheet view) and
click a command button that opens a form to display the record
selected.

How can I do this?

I tried to use the ActiveForm property to store the SubForm name but
this will only refer to a MainForm. Also, I don't know the syntax for
referring to a subform on a tabbed control.

Can anyone help?

Regards,

Jon



Sun, 13 Aug 2000 03:00:00 GMT  
 Storing subform name in variable when clicked

Jon,

I'll assume this command button is on the main form.  We'll call the
subform you're selecting the record in "Sfrm1", the main form "frmMain"
and the form you want to open "frm2".  

In OnClick of the command button,

dim stLink as string
stlink = "[name of id on frm2] = '" & me.[sfm1 CONTROL name on frmMain]_
 ![field to match to frm2] & "'"  

'(if you need other link criteria from frmMain or sfrm1 add them on)

DoCmd.OpenForm "frm2",,, stLink

This will open frm2 with the record selected on sfrm1.

Keri Hardwick

Quote:

> I have a main form with a tabbed control that contains a datasheet
> subform on each tab.

> I want to be able to click in one of the subforms (datasheet view) and
> click a command button that opens a form to display the record
> selected.

> How can I do this?

> I tried to use the ActiveForm property to store the SubForm name but
> this will only refer to a MainForm. Also, I don't know the syntax for
> referring to a subform on a tabbed control.

> Can anyone help?

> Regards,

> Jon



Sun, 13 Aug 2000 03:00:00 GMT  
 Storing subform name in variable when clicked

Hi Keri,

Thanks for the help. It works a treat.

There is one vital piece of information I may have left out.

I have a tabbed control with 4 different subforms, each tab page
having its own subform.

I need to store the name of the subform I've clicked in in a variable
so it can be used with your code.

Any suggestions on how I might do this?

Regards

Jon

Quote:
>Jon,

>I'll assume this command button is on the main form.  We'll call the
>subform you're selecting the record in "Sfrm1", the main form "frmMain"
>and the form you want to open "frm2".  

>In OnClick of the command button,

>dim stLink as string
>stlink = "[name of id on frm2] = '" & me.[sfm1 CONTROL name on frmMain]_
> ![field to match to frm2] & "'"  

>'(if you need other link criteria from frmMain or sfrm1 add them on)

>DoCmd.OpenForm "frm2",,, stLink

>This will open frm2 with the record selected on sfrm1.



Mon, 14 Aug 2000 03:00:00 GMT  
 Storing subform name in variable when clicked

You can determine which page is selected by using the PageIndex (see
Page Object and Pages collection in Help).  You can use a case statement
on the PageIndex to grab the subform control name.

Keri

Quote:

> Hi Keri,

> Thanks for the help. It works a treat.

> There is one vital piece of information I may have left out.

> I have a tabbed control with 4 different subforms, each tab page
> having its own subform.

> I need to store the name of the subform I've clicked in in a variable
> so it can be used with your code.

> Any suggestions on how I might do this?

> Regards

> Jon

> >Jon,

> >I'll assume this command button is on the main form.  We'll call the
> >subform you're selecting the record in "Sfrm1", the main form "frmMain"
> >and the form you want to open "frm2".

> >In OnClick of the command button,

> >dim stLink as string
> >stlink = "[name of id on frm2] = '" & me.[sfm1 CONTROL name on frmMain]_
> > ![field to match to frm2] & "'"

> >'(if you need other link criteria from frmMain or sfrm1 add them on)

> >DoCmd.OpenForm "frm2",,, stLink

> >This will open frm2 with the record selected on sfrm1.



Mon, 14 Aug 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Referencing a variable name stored in a variable

2. Variables stored in Range Names

3. Store the active worksheet(name) into variable

4. Setting a control who's name is stored in a variable

5. accessing control name stored in a variable

6. Reffering to Control when Name is stored in Variable

7. Storing active subform in variable

8. Temp QueryDef or Stored QueryDef Variable Name

9. Call Function using Func Name stored in variable

10. Help with storing variable name in a table


 
Powered by phpBB® Forum Software © phpBB Group