tab control and multi-column listbox

K

Kay

Hi

On my form I have a tab control with 2 tabs. The first tabs got text
boxes etc to insert records into. The second box shows all my records
in a multi-column list box. What code can I use so that when I double
click on a row in my multi-column listbox, the record is displayed in
the first tab.

Any help is much appreciated
 
G

Guest

Kay,

I have to make some assumptions in an effort to try to help.

First, I will assume that you have some kind of Key ID field for each of
your records. I will assume that the key field is an autonumber field. I
will also assume that you have that field as the first field in you list box
so that when double clicked, that value will be the value in the list box.

I will also assume that in your tab that has a field for the record ID.

You should set the visibility of your field for the record ID to No to make
it not visible.

All of this said, in the OnDoubleClick event of your list box you can use
code like:

Dim txtRecordID As Long
txtRecordID = Me.List28
With Me.txtRecordID
.Visible = True
.SetFocus
End With
DoCmd.FindRecord txtRecordID
Me.Page2.SetFocus
Me.txtFName.SetFocus
Me.txtPlayerID.Visible = False

In the code above you will need to substitute the nams of your specific
controls for the name I have (txtRecordID to the name of your control for the
Record ID field on the tab page with the text boxes.)

You could also place a button on the tab page that has the text boxes to
allow users to return to the list box page. To do this, just add a button and
then in the OnClick event of the button, add the following:
Me.Page1.SetFocus
Me.List28.Value = Null

One more item that might enhance your user interface would be to set the
Style property of your tab control to "None" this will remove that actual
tabs and then your code will simply display the record after the double click
and/or the list after the button is clicked.
 

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