SetFocus for a TabControl

J

Julie

I have a form (frmLSIR) with a command button. I want the command button to
open a form (frmAllInfo) for the primary key (SILSID) on frmLSI but to also
focus on a particular page on a tab control. Then I want to close frmLSIR

I have taught myself Access, so bare with me.

Here's what I have so far:

Private Sub cmdCloseLSIR_Click()
On Error GoTo Err_cmdCloseLSIR_Click

DoCmd.OpenForm "frmAllInfo", acNormal, "",
"SILSID=Forms!frmLSIR!SILSID", , acNormal

DoCmd.Close acForm, "frmLSIR"

Exit_cmdCloseLSIR_Click:
Exit Sub

Err_cmdCloseLSIR_Click:
MsgBox Err.Description
Resume Exit_cmdCloseLSIR_Click
End Sub


This works well. What I want is to add is this: tell Access to focus on the
tab control (tbFileInfo) page (pgAssessment). And I haven't been able to get
it to happen working with the code I already have.

Thank you
 
N

Nicholas Scarpinato

The line you're looking for is:

tbFileInfo.Pages(pgAssessment).SetFocus
 
N

Nicholas Scarpinato

Err... that should be:

tbFileInfo.Pages("pgAssessment").SetFocus

It needs the quotes when you're dealing with the page names. If you use the
index numbers of the pages, the first tab is page 0. To focus on the second
tab looks like this:

tbFileInfo.Pages(1).SetFocus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top