ListBox and Navigation on Unbound forms

D

d9pierce

Good morning all,

I actually have two questions similiar in relation.

First is I have an unbound form with a list box on it called lstData.
That is populated by a tbl_Titles. There are several txtBoxes and misc
that are populated by the lstData. I have added navigation buttons to
the form however I cannot get them to work. Does anyoone have any
reference to how to use the First, Previous, Next, and Last record
navagation on an unbound form?

Second, on the same form I have an unbound txtbox which I want to use
to give a record count. I currently am using Dcount method however
this can be rather slow as on many other forms I use a lot of filters
and just wondering if anyone has any sucessful ideas for this that
works well with filters on unbound forms to count records?

I wont go into the reasons why using unbound however I have many
reasons to why. Thanks
D9pierce
 
A

Al Campagna

D9pierce,
I'm not sure I understand... both questions do not apply to an unbound
form.
On an unbound form... there's no associated recordset, so what's to
navigate to, and what's to count?
If I've misunderstood... more detail please.
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
D

d9pierce

HI,
Currently I have a listbox on the unbound form that is populated by
records from a table. I have to click on the records in the listbox in
order to change from one record to another. I would like to use
navigation buttons to go to next, previous, ect.... records from the
listbox. By clicking on one of the records in the list box it
populates the other txtBoxes and such with information from that
record.

Private Sub lstData_AfterUpdate()

'--- whenever a new item is chosen in the list box, display the
data in text boxes
txtTitle = lstData.Column(1)
txtCreated = lstData.Column(2)
txtModified = lstData.Column(3)
chkRecordLock = lstData.Column(4)
txtDefinition = lstData.Column(5)
txtTitleId = lstData.Column(0)
chkRecordLock = True
Call chkRecordLock_Click
End Sub


Private Sub Form_Open(Cancel As Integer)


lstData.SetFocus
lstData = lstData.ItemData(0)
Call lstData_AfterUpdate
chkRecordLock = True
Call chkRecordLock_Click
cmdPrint.Enabled = True
End Sub

The point is I want to use some navigation buttons to navigate through
the records instead of clicking on them in the list box. I am sure
this is possible but cant figure it out.

Next I have a txtbox for the record count and this is the expression!
=DCount("[TitleId]","tbl_Title")
Which works fine however it can be very slow in forms using 150,000 or
more records and when using a lot of filters so I am looking for a
better way using code to perform this task rather than an expression.

I do hopes this helps clarify things and thank you.
 
A

Al Campagna

d9pierce,
First... a minor point. Please don't delete the previous posts from
your replies. Responders need to see the flow of the thread, as to what's
been tried, and what's been suggested. It's OK to <snip> non essential
text,
but do keep the crux of the entire conversation.

Since you don't want to discuss why you've chosen this unbound design...
and
it's associated difficulties in coding even minor tasks such as
navigation... I'll just
deal with the basic concept.

I'll assume what you mean by "Next" record, or "Previous" record would
be...
if you selected the 10th item in the list, "Next" would be the 11th item in
the list.
"Previous" would be associated with the 9th item.

Each selection in a combo or list can be referred to as
lstData.ItemData(0) (in
the case of the first item), lstData.ItemData(4) (in the case of the 5th
item)
etc... etc...
So your navigation will have to pick up on what the ItemData value is
and Add
or Subtract from there.

For First and Last, use ...
NumItems = lstData.ListCount
and use that value to set
lstData.ItemData(0) for "First", or lstData.ItemData(NumItems-1)
for "Last."
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

HI,
Currently I have a listbox on the unbound form that is populated by
records from a table. I have to click on the records in the listbox in
order to change from one record to another. I would like to use
navigation buttons to go to next, previous, ect.... records from the
listbox. By clicking on one of the records in the list box it
populates the other txtBoxes and such with information from that
record.

Private Sub lstData_AfterUpdate()

'--- whenever a new item is chosen in the list box, display the
data in text boxes
txtTitle = lstData.Column(1)
txtCreated = lstData.Column(2)
txtModified = lstData.Column(3)
chkRecordLock = lstData.Column(4)
txtDefinition = lstData.Column(5)
txtTitleId = lstData.Column(0)
chkRecordLock = True
Call chkRecordLock_Click
End Sub


Private Sub Form_Open(Cancel As Integer)


lstData.SetFocus
lstData = lstData.ItemData(0)
Call lstData_AfterUpdate
chkRecordLock = True
Call chkRecordLock_Click
cmdPrint.Enabled = True
End Sub

The point is I want to use some navigation buttons to navigate through
the records instead of clicking on them in the list box. I am sure
this is possible but cant figure it out.

Next I have a txtbox for the record count and this is the expression!
=DCount("[TitleId]","tbl_Title")
Which works fine however it can be very slow in forms using 150,000 or
more records and when using a lot of filters so I am looking for a
better way using code to perform this task rather than an expression.

I do hopes this helps clarify things and thank you.
 
B

Bill Benson

Al, correct me if I am wrong, but I don't think _AfterUpdate means anything
to an unbound control?


Al Campagna said:
d9pierce,
First... a minor point. Please don't delete the previous posts from
your replies. Responders need to see the flow of the thread, as to what's
been tried, and what's been suggested. It's OK to <snip> non essential
text,
but do keep the crux of the entire conversation.

Since you don't want to discuss why you've chosen this unbound
design... and
it's associated difficulties in coding even minor tasks such as
navigation... I'll just
deal with the basic concept.

I'll assume what you mean by "Next" record, or "Previous" record would
be...
if you selected the 10th item in the list, "Next" would be the 11th item
in the list.
"Previous" would be associated with the 9th item.

Each selection in a combo or list can be referred to as
lstData.ItemData(0) (in
the case of the first item), lstData.ItemData(4) (in the case of the 5th
item)
etc... etc...
So your navigation will have to pick up on what the ItemData value is
and Add
or Subtract from there.

For First and Last, use ...
NumItems = lstData.ListCount
and use that value to set
lstData.ItemData(0) for "First", or lstData.ItemData(NumItems-1)
for "Last."
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

HI,
Currently I have a listbox on the unbound form that is populated by
records from a table. I have to click on the records in the listbox in
order to change from one record to another. I would like to use
navigation buttons to go to next, previous, ect.... records from the
listbox. By clicking on one of the records in the list box it
populates the other txtBoxes and such with information from that
record.

Private Sub lstData_AfterUpdate()

'--- whenever a new item is chosen in the list box, display the
data in text boxes
txtTitle = lstData.Column(1)
txtCreated = lstData.Column(2)
txtModified = lstData.Column(3)
chkRecordLock = lstData.Column(4)
txtDefinition = lstData.Column(5)
txtTitleId = lstData.Column(0)
chkRecordLock = True
Call chkRecordLock_Click
End Sub


Private Sub Form_Open(Cancel As Integer)


lstData.SetFocus
lstData = lstData.ItemData(0)
Call lstData_AfterUpdate
chkRecordLock = True
Call chkRecordLock_Click
cmdPrint.Enabled = True
End Sub

The point is I want to use some navigation buttons to navigate through
the records instead of clicking on them in the list box. I am sure
this is possible but cant figure it out.

Next I have a txtbox for the record count and this is the expression!
=DCount("[TitleId]","tbl_Title")
Which works fine however it can be very slow in forms using 150,000 or
more records and when using a lot of filters so I am looking for a
better way using code to perform this task rather than an expression.

I do hopes this helps clarify things and thank you.
 
A

Al Campagna

Bill,
Sure it does. Place an unbound combo control on a form, and in the
AfterUpdate event, just put a Beep.
(You can use a Value List with "X"; "Y"; "Z")
Whenever you select any of those choices, the AfterUpdate event, and the
beep, occur. Choose any valye again... another beep... etc... etc...
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Bill Benson said:
Al, correct me if I am wrong, but I don't think _AfterUpdate means
anything to an unbound control?


Al Campagna said:
d9pierce,
First... a minor point. Please don't delete the previous posts from
your replies. Responders need to see the flow of the thread, as to
what's
been tried, and what's been suggested. It's OK to <snip> non essential
text,
but do keep the crux of the entire conversation.

Since you don't want to discuss why you've chosen this unbound
design... and
it's associated difficulties in coding even minor tasks such as
navigation... I'll just
deal with the basic concept.

I'll assume what you mean by "Next" record, or "Previous" record would
be...
if you selected the 10th item in the list, "Next" would be the 11th item
in the list.
"Previous" would be associated with the 9th item.

Each selection in a combo or list can be referred to as
lstData.ItemData(0) (in
the case of the first item), lstData.ItemData(4) (in the case of the 5th
item)
etc... etc...
So your navigation will have to pick up on what the ItemData value is
and Add
or Subtract from there.

For First and Last, use ...
NumItems = lstData.ListCount
and use that value to set
lstData.ItemData(0) for "First", or lstData.ItemData(NumItems-1)
for "Last."
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your
life."

HI,
Currently I have a listbox on the unbound form that is populated by
records from a table. I have to click on the records in the listbox in
order to change from one record to another. I would like to use
navigation buttons to go to next, previous, ect.... records from the
listbox. By clicking on one of the records in the list box it
populates the other txtBoxes and such with information from that
record.

Private Sub lstData_AfterUpdate()

'--- whenever a new item is chosen in the list box, display the
data in text boxes
txtTitle = lstData.Column(1)
txtCreated = lstData.Column(2)
txtModified = lstData.Column(3)
chkRecordLock = lstData.Column(4)
txtDefinition = lstData.Column(5)
txtTitleId = lstData.Column(0)
chkRecordLock = True
Call chkRecordLock_Click
End Sub


Private Sub Form_Open(Cancel As Integer)


lstData.SetFocus
lstData = lstData.ItemData(0)
Call lstData_AfterUpdate
chkRecordLock = True
Call chkRecordLock_Click
cmdPrint.Enabled = True
End Sub

The point is I want to use some navigation buttons to navigate through
the records instead of clicking on them in the list box. I am sure
this is possible but cant figure it out.

Next I have a txtbox for the record count and this is the expression!
=DCount("[TitleId]","tbl_Title")
Which works fine however it can be very slow in forms using 150,000 or
more records and when using a lot of filters so I am looking for a
better way using code to perform this task rather than an expression.

I do hopes this helps clarify things and thank you.
 
A

Al Campagna

Bill,
I had another thought that I thought I'd run by you.
An "unbound" control can have a calculation as a ControlSource,
and in that case... there would be no "logical" AfterUpdate event. It would
still have an AfterUpdate property... but it could not be manually
triggered.

However, an "unbound" control can have no ControlSource, and values
can be entered therein... and that control would have an AfterUpdate event.
I've often used an unbound combo box on the main form, to filter
multiple
records on that form's subform. Ex. I select a number from 1 to 36
(Loom numbers), and requery the sub to see all the jobs scheduled for that
Loom. (AfterUpdate... Requery the Subform...)
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Bill Benson said:
Al, correct me if I am wrong, but I don't think _AfterUpdate means
anything to an unbound control?


Al Campagna said:
d9pierce,
First... a minor point. Please don't delete the previous posts from
your replies. Responders need to see the flow of the thread, as to
what's
been tried, and what's been suggested. It's OK to <snip> non essential
text,
but do keep the crux of the entire conversation.

Since you don't want to discuss why you've chosen this unbound
design... and
it's associated difficulties in coding even minor tasks such as
navigation... I'll just
deal with the basic concept.

I'll assume what you mean by "Next" record, or "Previous" record would
be...
if you selected the 10th item in the list, "Next" would be the 11th item
in the list.
"Previous" would be associated with the 9th item.

Each selection in a combo or list can be referred to as
lstData.ItemData(0) (in
the case of the first item), lstData.ItemData(4) (in the case of the 5th
item)
etc... etc...
So your navigation will have to pick up on what the ItemData value is
and Add
or Subtract from there.

For First and Last, use ...
NumItems = lstData.ListCount
and use that value to set
lstData.ItemData(0) for "First", or lstData.ItemData(NumItems-1)
for "Last."
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your
life."

HI,
Currently I have a listbox on the unbound form that is populated by
records from a table. I have to click on the records in the listbox in
order to change from one record to another. I would like to use
navigation buttons to go to next, previous, ect.... records from the
listbox. By clicking on one of the records in the list box it
populates the other txtBoxes and such with information from that
record.

Private Sub lstData_AfterUpdate()

'--- whenever a new item is chosen in the list box, display the
data in text boxes
txtTitle = lstData.Column(1)
txtCreated = lstData.Column(2)
txtModified = lstData.Column(3)
chkRecordLock = lstData.Column(4)
txtDefinition = lstData.Column(5)
txtTitleId = lstData.Column(0)
chkRecordLock = True
Call chkRecordLock_Click
End Sub


Private Sub Form_Open(Cancel As Integer)


lstData.SetFocus
lstData = lstData.ItemData(0)
Call lstData_AfterUpdate
chkRecordLock = True
Call chkRecordLock_Click
cmdPrint.Enabled = True
End Sub

The point is I want to use some navigation buttons to navigate through
the records instead of clicking on them in the list box. I am sure
this is possible but cant figure it out.

Next I have a txtbox for the record count and this is the expression!
=DCount("[TitleId]","tbl_Title")
Which works fine however it can be very slow in forms using 150,000 or
more records and when using a lot of filters so I am looking for a
better way using code to perform this task rather than an expression.

I do hopes this helps clarify things and thank you.
 

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