List Box Rows

  • Thread starter Thread starter Manton
  • Start date Start date
M

Manton

I have a form which contains a list box (with four columns inside the box)
and next to the box there are several fields ie. A/c #, dates etc.
There is no tab stop for the list box.
There are existing records in the list box.
The user tabs through the existing fields and eventually goes on to the next
record.
Problem. When the user tabs/enters into the next record, the equivalent
record in the list box is not highlighted. The highlighted record in the
list box remains on the first record in the box. I want the list box to
show the record that the user is in (while working on the fields next to the
list box).

Listbox Property:
Unbound
Rowtype: Table/Query
Rowsource: SELECT [qry GSHREQ daily].[State],[qry GSHREQ daily].[A/c
#],[qry GSHREQ daily].[Status],[qry GSHREQ daily].[Date Requested] FROM [qry
GSHREQ daily];

in the module:
--------------------------
AfterUpdate:
Private Sub List18_AfterUpdate()
'Find the record that matches the control.
Dim rs As Object

Set rs=Me.Recordset.Clone
rs.FindFirst "[A/c #]='"&Me![List18] & ""'
Me.Bookmark=rs.Bookmark
End Sub
 
In the form's Current event, set the value of the listbox to match the
appropriate field in the form's current record. Judging by your use of AC#
to find a record when the user clicks in the listbox, this would probably be
the field to use for picking which row.

Example:
Set the Bound Column to the column with the AC#. Then in the form's Current
event:
Me.List18=Me.txtACNumber
 
thanks for the reply.

the list box has the following columns in their respective order:
State A/c # Status Date Requested

the bound column is set at 2 given the 2nd column relates to the A/c #
But when i entered Me.List18=Me.txtACNumber in the current event of
the form, the module window opened up with the error relating to the txt
part of the line.
Just to confirm: the current event your are refering to is the form or is it
the list box.
thanks.

Wayne Morgan said:
In the form's Current event, set the value of the listbox to match the
appropriate field in the form's current record. Judging by your use of AC#
to find a record when the user clicks in the listbox, this would probably be
the field to use for picking which row.

Example:
Set the Bound Column to the column with the AC#. Then in the form's Current
event:
Me.List18=Me.txtACNumber

--
Wayne Morgan
Microsoft Access MVP


Manton said:
I have a form which contains a list box (with four columns inside the box)
and next to the box there are several fields ie. A/c #, dates etc.
There is no tab stop for the list box.
There are existing records in the list box.
The user tabs through the existing fields and eventually goes on to the next
record.
Problem. When the user tabs/enters into the next record, the equivalent
record in the list box is not highlighted. The highlighted record in the
list box remains on the first record in the box. I want the list box to
show the record that the user is in (while working on the fields next to the
list box).

Listbox Property:
Unbound
Rowtype: Table/Query
Rowsource: SELECT [qry GSHREQ daily].[State],[qry GSHREQ daily].[A/c
#],[qry GSHREQ daily].[Status],[qry GSHREQ daily].[Date Requested] FROM [qry
GSHREQ daily];

in the module:
--------------------------
AfterUpdate:
Private Sub List18_AfterUpdate()
'Find the record that matches the control.
Dim rs As Object

Set rs=Me.Recordset.Clone
rs.FindFirst "[A/c #]='"&Me![List18] & ""'
Me.Bookmark=rs.Bookmark
End Sub
 
Did you enter exactly that? You need to change txtACNumber to the name of
the control on your form that contains that number.
 
Back
Top