PC Review


Reply
Thread Tools Rate Thread

Auto select first item in list box after selecting tab.

 
 
JK
Guest
Posts: n/a
 
      2nd Feb 2009
Any idea why this doesn't work? Maybe there is another way?

After a user selects a tab, I want to have the application auto-select the
first item in the list box. It works on the form load event but that's just
the first tab.

Private Sub pgMiscReports2_Click()
' auto-select the first item in the list box
Me!lstReports2.Selected(0) = True
Me.cmdOpenReports2.SetFocus
End Sub


Any help would be appreciated.

Thx,
Jason
 
Reply With Quote
 
 
 
 
fredg
Guest
Posts: n/a
 
      2nd Feb 2009
On Mon, 2 Feb 2009 06:31:02 -0800, JK wrote:

> Any idea why this doesn't work? Maybe there is another way?
>
> After a user selects a tab, I want to have the application auto-select the
> first item in the list box. It works on the form load event but that's just
> the first tab.
>
> Private Sub pgMiscReports2_Click()
> ' auto-select the first item in the list box
> Me!lstReports2.Selected(0) = True
> Me.cmdOpenReports2.SetFocus
> End Sub
>
> Any help would be appreciated.
>
> Thx,
> Jason


Me!lstReports2.ListIndex = 0
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      2nd Feb 2009
When you are working with a Tab control, you best bet is to use the tabs
Change event to do this type of thing:

Private Sub tab_MyTab_Change

'I like to refer to the caption rather than the page index
SELECT CASE me.tab_MyTab.pages(me.tab_MyTab).Caption
Case 1 "Caption1"
'some code here
Case "Misc Reports"
me.lstReports2 = me.lstReports.column(0, 0)
me.cmdOpenReporst2.SetFocus
Case Else
End Select

End sub

When you "select" the list item the way you are attempting to do, you are
not actually setting it's value. I prefer to actually set the value.
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"JK" wrote:

> Any idea why this doesn't work? Maybe there is another way?
>
> After a user selects a tab, I want to have the application auto-select the
> first item in the list box. It works on the form load event but that's just
> the first tab.
>
> Private Sub pgMiscReports2_Click()
> ' auto-select the first item in the list box
> Me!lstReports2.Selected(0) = True
> Me.cmdOpenReports2.SetFocus
> End Sub
>
>
> Any help would be appreciated.
>
> Thx,
> Jason

 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      2nd Feb 2009
Fred,

That won't work unless the listbox has the focus.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"fredg" wrote:

> On Mon, 2 Feb 2009 06:31:02 -0800, JK wrote:
>
> > Any idea why this doesn't work? Maybe there is another way?
> >
> > After a user selects a tab, I want to have the application auto-select the
> > first item in the list box. It works on the form load event but that's just
> > the first tab.
> >
> > Private Sub pgMiscReports2_Click()
> > ' auto-select the first item in the list box
> > Me!lstReports2.Selected(0) = True
> > Me.cmdOpenReports2.SetFocus
> > End Sub
> >
> > Any help would be appreciated.
> >
> > Thx,
> > Jason

>
> Me!lstReports2.ListIndex = 0
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
>

 
Reply With Quote
 
JK
Guest
Posts: n/a
 
      9th Feb 2009
I’m having trouble making your code work. I’m getting an error after Case 1
“Caption1.” I’m putting the first tab's caption in that field. The error I’m
getting says Expected: End of Statement.

My form has six tabs.

Tab Control Name: TabCtl8

Tab #1
Name: pgMiscReports
Caption: Re&ports (1)
List Box: lstForms3
Open Button: cmdOpenForm2

Tab #2
Name: pgMiscReports2
Caption: Repor&ts (2)
List Box: lstReports2
Open Button: cmdOpenReports2

This is how I started, but I must be doing something wrong?

Private Sub TabCtl8_Change()
'I like to refer to the caption rather than the page index
Select Case Me.TabCtl8.Pages(Me.TabCtl8).Caption
Case 1 "Re&ports (1)" ‘THIS IS WHERE I GET AN ERROR
'some code here
Case "pgMiscReports"
Me.lstForms3 = Me.lstForms3.Column(0, 0)
Me.cmdOpenForm2.SetFocus
Case Else
End Select


Thx.
Jason


"Dale Fye" wrote:

> When you are working with a Tab control, you best bet is to use the tabs
> Change event to do this type of thing:
>
> Private Sub tab_MyTab_Change
>
> 'I like to refer to the caption rather than the page index
> SELECT CASE me.tab_MyTab.pages(me.tab_MyTab).Caption
> Case 1 "Caption1"
> 'some code here
> Case "Misc Reports"
> me.lstReports2 = me.lstReports.column(0, 0)
> me.cmdOpenReporst2.SetFocus
> Case Else
> End Select
>
> End sub
>
> When you "select" the list item the way you are attempting to do, you are
> not actually setting it's value. I prefer to actually set the value.
> --
> HTH
> Dale
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "JK" wrote:
>
> > Any idea why this doesn't work? Maybe there is another way?
> >
> > After a user selects a tab, I want to have the application auto-select the
> > first item in the list box. It works on the form load event but that's just
> > the first tab.
> >
> > Private Sub pgMiscReports2_Click()
> > ' auto-select the first item in the list box
> > Me!lstReports2.Selected(0) = True
> > Me.cmdOpenReports2.SetFocus
> > End Sub
> >
> >
> > Any help would be appreciated.
> >
> > Thx,
> > Jason

 
Reply With Quote
 
JK
Guest
Posts: n/a
 
      9th Feb 2009
I’m having trouble making your code work. I’m getting an error after Case 1
“Caption1.” I’m putting the first tab's caption in that field. The error I’m
getting says Expected: End of Statement.

My form has six tabs.

Tab Control Name: TabCtl8

Tab #1
Name: pgMiscReports
Caption: Re&ports (1)
List Box: lstForms3
Open Button: cmdOpenForm2

Tab #2
Name: pgMiscReports2
Caption: Repor&ts (2)
List Box: lstReports2
Open Button: cmdOpenReports2

This is how I started, but I must be doing something wrong?

Private Sub TabCtl8_Change()
'I like to refer to the caption rather than the page index
Select Case Me.TabCtl8.Pages(Me.TabCtl8).Caption
Case 1 "Re&ports (1)" ‘THIS IS WHERE I GET AN ERROR
'some code here
Case "pgMiscReports"
Me.lstForms3 = Me.lstForms3.Column(0, 0)
Me.cmdOpenForm2.SetFocus
Case Else
End Select


Thx.
Jason


"Dale Fye" wrote:

> When you are working with a Tab control, you best bet is to use the tabs
> Change event to do this type of thing:
>
> Private Sub tab_MyTab_Change
>
> 'I like to refer to the caption rather than the page index
> SELECT CASE me.tab_MyTab.pages(me.tab_MyTab).Caption
> Case 1 "Caption1"
> 'some code here
> Case "Misc Reports"
> me.lstReports2 = me.lstReports.column(0, 0)
> me.cmdOpenReporst2.SetFocus
> Case Else
> End Select
>
> End sub
>
> When you "select" the list item the way you are attempting to do, you are
> not actually setting it's value. I prefer to actually set the value.
> --
> HTH
> Dale
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "JK" wrote:
>
> > Any idea why this doesn't work? Maybe there is another way?
> >
> > After a user selects a tab, I want to have the application auto-select the
> > first item in the list box. It works on the form load event but that's just
> > the first tab.
> >
> > Private Sub pgMiscReports2_Click()
> > ' auto-select the first item in the list box
> > Me!lstReports2.Selected(0) = True
> > Me.cmdOpenReports2.SetFocus
> > End Sub
> >
> >
> > Any help would be appreciated.
> >
> > Thx,
> > Jason

 
Reply With Quote
 
JK
Guest
Posts: n/a
 
      9th Feb 2009
I’m having trouble making your code work. I’m getting an error after Case 1
“Caption1.” I’m putting the first tab's caption in that field. The error I’m
getting says Expected: End of Statement.

My form has six tabs.

Tab Control Name: TabCtl8

Tab #1
Name: pgMiscReports
Caption: Re&ports (1)
List Box: lstForms3
Open Button: cmdOpenForm2

Tab #2
Name: pgMiscReports2
Caption: Repor&ts (2)
List Box: lstReports2
Open Button: cmdOpenReports2

This is how I started, but I must be doing something wrong?

Private Sub TabCtl8_Change()
'I like to refer to the caption rather than the page index
Select Case Me.TabCtl8.Pages(Me.TabCtl8).Caption
Case 1 "Re&ports (1)" ‘THIS IS WHERE I GET AN ERROR
'some code here
Case "pgMiscReports"
Me.lstForms3 = Me.lstForms3.Column(0, 0)
Me.cmdOpenForm2.SetFocus
Case Else
End Select


Thx.
Jason


"Dale Fye" wrote:

> When you are working with a Tab control, you best bet is to use the tabs
> Change event to do this type of thing:
>
> Private Sub tab_MyTab_Change
>
> 'I like to refer to the caption rather than the page index
> SELECT CASE me.tab_MyTab.pages(me.tab_MyTab).Caption
> Case 1 "Caption1"
> 'some code here
> Case "Misc Reports"
> me.lstReports2 = me.lstReports.column(0, 0)
> me.cmdOpenReporst2.SetFocus
> Case Else
> End Select
>
> End sub
>
> When you "select" the list item the way you are attempting to do, you are
> not actually setting it's value. I prefer to actually set the value.
> --
> HTH
> Dale
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "JK" wrote:
>
> > Any idea why this doesn't work? Maybe there is another way?
> >
> > After a user selects a tab, I want to have the application auto-select the
> > first item in the list box. It works on the form load event but that's just
> > the first tab.
> >
> > Private Sub pgMiscReports2_Click()
> > ' auto-select the first item in the list box
> > Me!lstReports2.Selected(0) = True
> > Me.cmdOpenReports2.SetFocus
> > End Sub
> >
> >
> > Any help would be appreciated.
> >
> > Thx,
> > Jason


"Dale Fye" wrote:

> When you are working with a Tab control, you best bet is to use the tabs
> Change event to do this type of thing:
>
> Private Sub tab_MyTab_Change
>
> 'I like to refer to the caption rather than the page index
> SELECT CASE me.tab_MyTab.pages(me.tab_MyTab).Caption
> Case 1 "Caption1"
> 'some code here
> Case "Misc Reports"
> me.lstReports2 = me.lstReports.column(0, 0)
> me.cmdOpenReporst2.SetFocus
> Case Else
> End Select
>
> End sub
>
> When you "select" the list item the way you are attempting to do, you are
> not actually setting it's value. I prefer to actually set the value.
> --
> HTH
> Dale
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "JK" wrote:
>
> > Any idea why this doesn't work? Maybe there is another way?
> >
> > After a user selects a tab, I want to have the application auto-select the
> > first item in the list box. It works on the form load event but that's just
> > the first tab.
> >
> > Private Sub pgMiscReports2_Click()
> > ' auto-select the first item in the list box
> > Me!lstReports2.Selected(0) = True
> > Me.cmdOpenReports2.SetFocus
> > End Sub
> >
> >
> > Any help would be appreciated.
> >
> > Thx,
> > Jason

 
Reply With Quote
 
JK
Guest
Posts: n/a
 
      9th Feb 2009
I’m having trouble making your code work. I’m getting an error after Case 1
“Caption1.” I’m putting the first tab's caption in that field. The error I’m
getting says Expected: End of Statement.

My form has six tabs.

Tab Control Name: TabCtl8

Tab #1
Name: pgMiscReports
Caption: Re&ports (1)
List Box: lstForms3
Open Button: cmdOpenForm2

Tab #2
Name: pgMiscReports2
Caption: Repor&ts (2)
List Box: lstReports2
Open Button: cmdOpenReports2

This is how I started, but I must be doing something wrong?

Private Sub TabCtl8_Change()
'I like to refer to the caption rather than the page index
Select Case Me.TabCtl8.Pages(Me.TabCtl8).Caption
Case 1 "Re&ports (1)" ‘THIS IS WHERE I GET AN ERROR
'some code here
Case "pgMiscReports"
Me.lstForms3 = Me.lstForms3.Column(0, 0)
Me.cmdOpenForm2.SetFocus
Case Else
End Select


Thx.
Jason


"Dale Fye" wrote:

> Fred,
>
> That won't work unless the listbox has the focus.
>
> --
> HTH
> Dale
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "fredg" wrote:
>
> > On Mon, 2 Feb 2009 06:31:02 -0800, JK wrote:
> >
> > > Any idea why this doesn't work? Maybe there is another way?
> > >
> > > After a user selects a tab, I want to have the application auto-select the
> > > first item in the list box. It works on the form load event but that's just
> > > the first tab.
> > >
> > > Private Sub pgMiscReports2_Click()
> > > ' auto-select the first item in the list box
> > > Me!lstReports2.Selected(0) = True
> > > Me.cmdOpenReports2.SetFocus
> > > End Sub
> > >
> > > Any help would be appreciated.
> > >
> > > Thx,
> > > Jason

> >
> > Me!lstReports2.ListIndex = 0
> > --
> > Fred
> > Please respond only to this newsgroup.
> > I do not reply to personal e-mail
> >

 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      9th Feb 2009
Change:
Case 1 "Re&ports (1)" ‘THIS IS WHERE I GET AN ERROR
to:
Case "Re&ports (1)"


If you prefer, you can use the controls name:

Select Case me.TabCtl8.Pages(me.TabCtl8).Name
Case "pgMiscReports"
msgbox "pgMiscReports"
Case "pgMiscReports2"
msgbox "pgMiscReports2"
Case else
msgbox "else"
End Select
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"JK" wrote:

> I’m having trouble making your code work. I’m getting an error after Case 1
> “Caption1.” I’m putting the first tab's caption in that field. The error I’m
> getting says Expected: End of Statement.
>
> My form has six tabs.
>
> Tab Control Name: TabCtl8
>
> Tab #1
> Name: pgMiscReports
> Caption: Re&ports (1)
> List Box: lstForms3
> Open Button: cmdOpenForm2
>
> Tab #2
> Name: pgMiscReports2
> Caption: Repor&ts (2)
> List Box: lstReports2
> Open Button: cmdOpenReports2
>
> This is how I started, but I must be doing something wrong?
>
> Private Sub TabCtl8_Change()
> 'I like to refer to the caption rather than the page index
> Select Case Me.TabCtl8.Pages(Me.TabCtl8).Caption
> Case 1 "Re&ports (1)" ‘THIS IS WHERE I GET AN ERROR
> 'some code here
> Case "pgMiscReports"
> Me.lstForms3 = Me.lstForms3.Column(0, 0)
> Me.cmdOpenForm2.SetFocus
> Case Else
> End Select
>
>
> Thx.
> Jason
>
>
> "Dale Fye" wrote:
>
> > When you are working with a Tab control, you best bet is to use the tabs
> > Change event to do this type of thing:
> >
> > Private Sub tab_MyTab_Change
> >
> > 'I like to refer to the caption rather than the page index
> > SELECT CASE me.tab_MyTab.pages(me.tab_MyTab).Caption
> > Case 1 "Caption1"
> > 'some code here
> > Case "Misc Reports"
> > me.lstReports2 = me.lstReports.column(0, 0)
> > me.cmdOpenReporst2.SetFocus
> > Case Else
> > End Select
> >
> > End sub
> >
> > When you "select" the list item the way you are attempting to do, you are
> > not actually setting it's value. I prefer to actually set the value.
> > --
> > HTH
> > Dale
> >
> > email address is invalid
> > Please reply to newsgroup only.
> >
> >
> >
> > "JK" wrote:
> >
> > > Any idea why this doesn't work? Maybe there is another way?
> > >
> > > After a user selects a tab, I want to have the application auto-select the
> > > first item in the list box. It works on the form load event but that's just
> > > the first tab.
> > >
> > > Private Sub pgMiscReports2_Click()
> > > ' auto-select the first item in the list box
> > > Me!lstReports2.Selected(0) = True
> > > Me.cmdOpenReports2.SetFocus
> > > End Sub
> > >
> > >
> > > Any help would be appreciated.
> > >
> > > Thx,
> > > Jason

>
> "Dale Fye" wrote:
>
> > When you are working with a Tab control, you best bet is to use the tabs
> > Change event to do this type of thing:
> >
> > Private Sub tab_MyTab_Change
> >
> > 'I like to refer to the caption rather than the page index
> > SELECT CASE me.tab_MyTab.pages(me.tab_MyTab).Caption
> > Case 1 "Caption1"
> > 'some code here
> > Case "Misc Reports"
> > me.lstReports2 = me.lstReports.column(0, 0)
> > me.cmdOpenReporst2.SetFocus
> > Case Else
> > End Select
> >
> > End sub
> >
> > When you "select" the list item the way you are attempting to do, you are
> > not actually setting it's value. I prefer to actually set the value.
> > --
> > HTH
> > Dale
> >
> > email address is invalid
> > Please reply to newsgroup only.
> >
> >
> >
> > "JK" wrote:
> >
> > > Any idea why this doesn't work? Maybe there is another way?
> > >
> > > After a user selects a tab, I want to have the application auto-select the
> > > first item in the list box. It works on the form load event but that's just
> > > the first tab.
> > >
> > > Private Sub pgMiscReports2_Click()
> > > ' auto-select the first item in the list box
> > > Me!lstReports2.Selected(0) = True
> > > Me.cmdOpenReports2.SetFocus
> > > End Sub
> > >
> > >
> > > Any help would be appreciated.
> > >
> > > Thx,
> > > Jason

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select a list in 1 cell by selecting an item from another list in Jonners Microsoft Excel Misc 2 10th Jul 2009 10:31 PM
Re: SELECTING AN ITEM FROM AUTO FILTER ! jay dean Microsoft Excel Programming 0 19th Apr 2009 10:04 PM
auto selecting the 1st item in a list view... Brad Pears Microsoft VB .NET 6 27th Jul 2007 12:30 AM
Auto copy/ paste on relevant work sheet when selecting list item =?Utf-8?B?TmlyYWogTWFuZ2xhbQ==?= Microsoft Excel Programming 1 6th Jun 2006 03:13 PM
Select item from dropdown list, item code is displayed in cell Meghan Microsoft Excel Misc 2 14th Oct 2003 08:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:18 PM.