List box behaviour Rli

G

Guest

I do not have a profound knowledge of visual basic but i try to learn...

My problem is:
I have access database with about 1000 records that have some 20 fields.
The first field is called [projectnumber]
I make a access form to display all these fields in a 'single form' manner
(displaying all fields of one record at the time and a next-record button and
a previous-record button).

Now i want to show on the same form a list of all available projectnumbers
in order to make it possible to click on a projectnumber and bring up the
corresponding values of the other fields.

So i create a unbound list-box (called [listbox1]) with a vertical scrollbar
and with in the Row Source a 'stripped' query for the projectnumbers based on
the same query as the form itself.

With an After Update event on [listbox1] i call this Sub:

Private Sub listbox1_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Projectnumber] = '" & Me![listbox1] & "'"
Me.Bookmark = rs.Bookmark
End Sub

That does work fine....click on a projectnumber in the list highlights that
number and brings up de values of that record in the other fields.

Now my problem is....
when i go to an other record with the next-record botton i want the
highlighted number in the listbox1 to follow.....

simply inverting the Sub as follows:
Private Sub projectnr_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Listbox1] = '" & Me![projectnumber] & "'"
Me.Bookmark = rs.Bookmark
End Sub

doe not work...

can anyone help me ?????
 
G

Guest

Okay....its simple like that....squeezing my brains for hours..thanks

Dan Artuso said:
Hi,
I think you'd want something like this:
Me.Listbox1 = Me.projectnumber

--
HTH
Dan Artuso, Access MVP


Rli said:
I do not have a profound knowledge of visual basic but i try to learn...

My problem is:
I have access database with about 1000 records that have some 20 fields.
The first field is called [projectnumber]
I make a access form to display all these fields in a 'single form' manner
(displaying all fields of one record at the time and a next-record button and
a previous-record button).

Now i want to show on the same form a list of all available projectnumbers
in order to make it possible to click on a projectnumber and bring up the
corresponding values of the other fields.

So i create a unbound list-box (called [listbox1]) with a vertical scrollbar
and with in the Row Source a 'stripped' query for the projectnumbers based on
the same query as the form itself.

With an After Update event on [listbox1] i call this Sub:

Private Sub listbox1_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Projectnumber] = '" & Me![listbox1] & "'"
Me.Bookmark = rs.Bookmark
End Sub

That does work fine....click on a projectnumber in the list highlights that
number and brings up de values of that record in the other fields.

Now my problem is....
when i go to an other record with the next-record botton i want the
highlighted number in the listbox1 to follow.....

simply inverting the Sub as follows:
Private Sub projectnr_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Listbox1] = '" & Me![projectnumber] & "'"
Me.Bookmark = rs.Bookmark
End Sub

doe not work...

can anyone help me ?????
 

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

Textbox Filter 4
Error 2147352567 2
RunTime Error 3070 8
Searching 3
Error 2237 8
Copy Record Button Function 1
More apostrophes!! 6
Recordset Clone using Autonumber 3

Top