Selecting First Row of List Box


J

JamesJ

I'm using a combo box based on a look-up field to filter the rows displayed
in a list box. At the end of the code for the AfterUpdate of the combo box
I use the following to "select' the first row:

Me!lstTitle.Selected(0) = True

After making a selection in the combo box and the records get filtered
the first row in the list box is highlighted but not selected. By that
I mean the dotted line around the row is not present and I must click on a
row in order to use the up and down arrow keys to move about.
What do I need to add so I don't have to click on a list box row in order to
use
the up and down arrow keys?
Also, if you might indulge me. I want to try my luck at using the List View
control
to display my data and was wondering if there was a web site you might point
me to
that deals with List View control and beginners?
I haven't had much luck with it in the past but I'm currently laid off and
have much
free time.

Thanks,
James.
 
Ad

Advertisements

R

RonaldoOneNil

After this line
Me!lstTitle.Selected(0) = True
put this
Me!lstTitle.SetFocus
 
J

JamesJ

The instruction file is a doc file and although I can open it in
wordpad I can't read much of it.
Anyway to convert this file to a txt or rtf?

James
 
Ad

Advertisements

P

Peter Hibbs

James,

I have sent a PDF version of the instruction document which you can
read with Acrobat Reader. The document has some instructions on using
the flex grid control.

Peter Hibbs.
 
J

JamesJ

Thanks much! It's appreciated!

James

Peter Hibbs said:
James,

I have sent a PDF version of the instruction document which you can
read with Acrobat Reader. The document has some instructions on using
the flex grid control.

Peter Hibbs.
 
D

Dale Fye

Although changing the Selected property will highlight the record, it will
not actually change the value. If the multi-select property of the listbox
is "None", then you should be able to do:

me.lstTitle.SetFocus
me.lstTitle.listindex = 0

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
J

JamesJ

Doesn't work. I still need to click in the list box.
Here's the entire code for the AfterUpdate of the cbo.

Private Sub cboDvdFilter_AfterUpdate()

Dim strSQL As String
Dim strAll As String

If Me!cboDvdFilter.Column(1) = "<<All>>" Then

strAll = "SELECT * FROM tblDvd ORDER BY DvdMovieTypeID, DvdMovieTitle;"
Me.RecordSource = strAll
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True ' I remarked this out but I did try it
first
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0


Else

strSQL = "SELECT * FROM tblDvd WHERE (((DvdMovieTypeID)=" &
[cboDvdFilter].[Value] & "))ORDER BY DvdMovieTypeID, DvdMovieTitle;"
Me.RecordSource = strSQL
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0

End If

End Sub
 
J

JamesJ

Where exactly did you send it?

James

Peter Hibbs said:
James,

I have sent a PDF version of the instruction document which you can
read with Acrobat Reader. The document has some instructions on using
the flex grid control.

Peter Hibbs.
 
Ad

Advertisements

D

Dale Fye

I missed the part that you wanted to be able to use the up and down buttons
without clicking.

Try:

Me.lstTitle.SetFocus
Me.lstTitle = Me.lstTitle.Column(Me.lstTitle.BoundColumn - 1, 0)


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



JamesJ said:
Doesn't work. I still need to click in the list box.
Here's the entire code for the AfterUpdate of the cbo.

Private Sub cboDvdFilter_AfterUpdate()

Dim strSQL As String
Dim strAll As String

If Me!cboDvdFilter.Column(1) = "<<All>>" Then

strAll = "SELECT * FROM tblDvd ORDER BY DvdMovieTypeID, DvdMovieTitle;"
Me.RecordSource = strAll
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True ' I remarked this out but I did try it
first
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0


Else

strSQL = "SELECT * FROM tblDvd WHERE (((DvdMovieTypeID)=" &
[cboDvdFilter].[Value] & "))ORDER BY DvdMovieTypeID, DvdMovieTitle;"
Me.RecordSource = strSQL
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0

End If

End Sub

Dale Fye said:
Although changing the Selected property will highlight the record, it will
not actually change the value. If the multi-select property of the
listbox
is "None", then you should be able to do:

me.lstTitle.SetFocus
me.lstTitle.listindex = 0

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
J

JamesJ

Isn't working either.
I want to use the Up/Down Arrow keys without having to click on
a row in the List Box.

James

Dale Fye said:
I missed the part that you wanted to be able to use the up and down buttons
without clicking.

Try:

Me.lstTitle.SetFocus
Me.lstTitle = Me.lstTitle.Column(Me.lstTitle.BoundColumn - 1, 0)


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



JamesJ said:
Doesn't work. I still need to click in the list box.
Here's the entire code for the AfterUpdate of the cbo.

Private Sub cboDvdFilter_AfterUpdate()

Dim strSQL As String
Dim strAll As String

If Me!cboDvdFilter.Column(1) = "<<All>>" Then

strAll = "SELECT * FROM tblDvd ORDER BY DvdMovieTypeID,
DvdMovieTitle;"
Me.RecordSource = strAll
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True ' I remarked this out but I did try
it
first
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0


Else

strSQL = "SELECT * FROM tblDvd WHERE (((DvdMovieTypeID)=" &
[cboDvdFilter].[Value] & "))ORDER BY DvdMovieTypeID, DvdMovieTitle;"
Me.RecordSource = strSQL
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0

End If

End Sub

Dale Fye said:
Although changing the Selected property will highlight the record, it
will
not actually change the value. If the multi-select property of the
listbox
is "None", then you should be able to do:

me.lstTitle.SetFocus
me.lstTitle.listindex = 0

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



:

I'm using a combo box based on a look-up field to filter the rows
displayed
in a list box. At the end of the code for the AfterUpdate of the combo
box
I use the following to "select' the first row:

Me!lstTitle.Selected(0) = True

After making a selection in the combo box and the records get filtered
the first row in the list box is highlighted but not selected. By that
I mean the dotted line around the row is not present and I must click
on
a
row in order to use the up and down arrow keys to move about.
What do I need to add so I don't have to click on a list box row in
order
to
use
the up and down arrow keys?
Also, if you might indulge me. I want to try my luck at using the List
View
control
to display my data and was wondering if there was a web site you might
point
me to
that deals with List View control and beginners?
I haven't had much luck with it in the past but I'm currently laid off
and
have much
free time.

Thanks,
James.
 
D

Dale Fye

That worked for me.

I added a command button to my form and used the latest code I provided to
change the value of the listbox, and set the focus to the list. As soon as I
clicked the command button, the appropiate row (I tried several) in the
listbox was highlighted and had the dashed line around it.

I was able to immediately use the up and down arrow keys to change the
selected row in the list.

Have you checked to make sure that the list has the Multiselect property set
to None?
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



JamesJ said:
Isn't working either.
I want to use the Up/Down Arrow keys without having to click on
a row in the List Box.

James

Dale Fye said:
I missed the part that you wanted to be able to use the up and down buttons
without clicking.

Try:

Me.lstTitle.SetFocus
Me.lstTitle = Me.lstTitle.Column(Me.lstTitle.BoundColumn - 1, 0)


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



JamesJ said:
Doesn't work. I still need to click in the list box.
Here's the entire code for the AfterUpdate of the cbo.

Private Sub cboDvdFilter_AfterUpdate()

Dim strSQL As String
Dim strAll As String

If Me!cboDvdFilter.Column(1) = "<<All>>" Then

strAll = "SELECT * FROM tblDvd ORDER BY DvdMovieTypeID,
DvdMovieTitle;"
Me.RecordSource = strAll
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True ' I remarked this out but I did try
it
first
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0


Else

strSQL = "SELECT * FROM tblDvd WHERE (((DvdMovieTypeID)=" &
[cboDvdFilter].[Value] & "))ORDER BY DvdMovieTypeID, DvdMovieTitle;"
Me.RecordSource = strSQL
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0

End If

End Sub

Although changing the Selected property will highlight the record, it
will
not actually change the value. If the multi-select property of the
listbox
is "None", then you should be able to do:

me.lstTitle.SetFocus
me.lstTitle.listindex = 0

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



:

I'm using a combo box based on a look-up field to filter the rows
displayed
in a list box. At the end of the code for the AfterUpdate of the combo
box
I use the following to "select' the first row:

Me!lstTitle.Selected(0) = True

After making a selection in the combo box and the records get filtered
the first row in the list box is highlighted but not selected. By that
I mean the dotted line around the row is not present and I must click
on
a
row in order to use the up and down arrow keys to move about.
What do I need to add so I don't have to click on a list box row in
order
to
use
the up and down arrow keys?
Also, if you might indulge me. I want to try my luck at using the List
View
control
to display my data and was wondering if there was a web site you might
point
me to
that deals with List View control and beginners?
I haven't had much luck with it in the past but I'm currently laid off
and
have much
free time.

Thanks,
James.
 
J

JamesJ

Multiselect is set to None.

James

Dale Fye said:
That worked for me.

I added a command button to my form and used the latest code I provided to
change the value of the listbox, and set the focus to the list. As soon as
I
clicked the command button, the appropiate row (I tried several) in the
listbox was highlighted and had the dashed line around it.

I was able to immediately use the up and down arrow keys to change the
selected row in the list.

Have you checked to make sure that the list has the Multiselect property
set
to None?
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



JamesJ said:
Isn't working either.
I want to use the Up/Down Arrow keys without having to click on
a row in the List Box.

James

Dale Fye said:
I missed the part that you wanted to be able to use the up and down
buttons
without clicking.

Try:

Me.lstTitle.SetFocus
Me.lstTitle = Me.lstTitle.Column(Me.lstTitle.BoundColumn - 1, 0)


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



:

Doesn't work. I still need to click in the list box.
Here's the entire code for the AfterUpdate of the cbo.

Private Sub cboDvdFilter_AfterUpdate()

Dim strSQL As String
Dim strAll As String

If Me!cboDvdFilter.Column(1) = "<<All>>" Then

strAll = "SELECT * FROM tblDvd ORDER BY DvdMovieTypeID,
DvdMovieTitle;"
Me.RecordSource = strAll
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True ' I remarked this out but I did
try
it
first
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0


Else

strSQL = "SELECT * FROM tblDvd WHERE (((DvdMovieTypeID)=" &
[cboDvdFilter].[Value] & "))ORDER BY DvdMovieTypeID, DvdMovieTitle;"
Me.RecordSource = strSQL
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0

End If

End Sub

Although changing the Selected property will highlight the record,
it
will
not actually change the value. If the multi-select property of the
listbox
is "None", then you should be able to do:

me.lstTitle.SetFocus
me.lstTitle.listindex = 0

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



:

I'm using a combo box based on a look-up field to filter the rows
displayed
in a list box. At the end of the code for the AfterUpdate of the
combo
box
I use the following to "select' the first row:

Me!lstTitle.Selected(0) = True

After making a selection in the combo box and the records get
filtered
the first row in the list box is highlighted but not selected. By
that
I mean the dotted line around the row is not present and I must
click
on
a
row in order to use the up and down arrow keys to move about.
What do I need to add so I don't have to click on a list box row in
order
to
use
the up and down arrow keys?
Also, if you might indulge me. I want to try my luck at using the
List
View
control
to display my data and was wondering if there was a web site you
might
point
me to
that deals with List View control and beginners?
I haven't had much luck with it in the past but I'm currently laid
off
and
have much
free time.

Thanks,
James.
 
P

Peter Hibbs

James,

I sent it to the email address that you used when you emailed me,
perhaps something went wrong there. Anyway, I have tried sending it
again, if you do not receive it this time, email me again.

Peter Hibbs.
 
Ad

Advertisements

J

JamesJ

Got it.

Peter Hibbs said:
James,

I sent it to the email address that you used when you emailed me,
perhaps something went wrong there. Anyway, I have tried sending it
again, if you do not receive it this time, email me again.

Peter Hibbs.
 
Ad

Advertisements

J

JamesJ

Found something out that seems odd.
I'm using a custom Navigation Pane to open my forms. I've noticed
that when I hover over a Nav item the dotted line disappears on
the selected list box item. If I have 2 forms open in my tabbed db
and I hover over one of the items in the Nav pane 'till the darker
back color shows the dotted line disappears. When I select the form
in the Nav pane the dotted lines appear again. Clear??
Just out of curiosity I have a non-tabbed db which when open I hide the
Nav pane using DoCmd.RunCommand acCmdWindowHide
The same forms but I have no problem with this. The dotted line is
around the selected row in the list box and I'm able to use the up/down
arrow keys to move around.

James

Dale Fye said:
That worked for me.

I added a command button to my form and used the latest code I provided to
change the value of the listbox, and set the focus to the list. As soon as
I
clicked the command button, the appropiate row (I tried several) in the
listbox was highlighted and had the dashed line around it.

I was able to immediately use the up and down arrow keys to change the
selected row in the list.

Have you checked to make sure that the list has the Multiselect property
set
to None?
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



JamesJ said:
Isn't working either.
I want to use the Up/Down Arrow keys without having to click on
a row in the List Box.

James

Dale Fye said:
I missed the part that you wanted to be able to use the up and down
buttons
without clicking.

Try:

Me.lstTitle.SetFocus
Me.lstTitle = Me.lstTitle.Column(Me.lstTitle.BoundColumn - 1, 0)


--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



:

Doesn't work. I still need to click in the list box.
Here's the entire code for the AfterUpdate of the cbo.

Private Sub cboDvdFilter_AfterUpdate()

Dim strSQL As String
Dim strAll As String

If Me!cboDvdFilter.Column(1) = "<<All>>" Then

strAll = "SELECT * FROM tblDvd ORDER BY DvdMovieTypeID,
DvdMovieTitle;"
Me.RecordSource = strAll
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True ' I remarked this out but I did
try
it
first
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0


Else

strSQL = "SELECT * FROM tblDvd WHERE (((DvdMovieTypeID)=" &
[cboDvdFilter].[Value] & "))ORDER BY DvdMovieTypeID, DvdMovieTitle;"
Me.RecordSource = strSQL
Me!lstTitle.RowSource = Me.RecordSource
'Me!lstTitle.Selected(0) = True
Me.lstTitle.SetFocus
Me.lstTitle.ListIndex = 0

End If

End Sub

Although changing the Selected property will highlight the record,
it
will
not actually change the value. If the multi-select property of the
listbox
is "None", then you should be able to do:

me.lstTitle.SetFocus
me.lstTitle.listindex = 0

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



:

I'm using a combo box based on a look-up field to filter the rows
displayed
in a list box. At the end of the code for the AfterUpdate of the
combo
box
I use the following to "select' the first row:

Me!lstTitle.Selected(0) = True

After making a selection in the combo box and the records get
filtered
the first row in the list box is highlighted but not selected. By
that
I mean the dotted line around the row is not present and I must
click
on
a
row in order to use the up and down arrow keys to move about.
What do I need to add so I don't have to click on a list box row in
order
to
use
the up and down arrow keys?
Also, if you might indulge me. I want to try my luck at using the
List
View
control
to display my data and was wondering if there was a web site you
might
point
me to
that deals with List View control and beginners?
I haven't had much luck with it in the past but I'm currently laid
off
and
have much
free time.

Thanks,
James.
 

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

Similar Threads


Top