Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, I am using MS Access 2000

Status
Not open for further replies.

RKAccess

Technical User
Sep 8, 2002
5
0
0
US
Hello,

I am using MS Access 2000.

I have a Main Form with a Listbox and a Subform. The Subform has various fields that correspond to a value selected from the Listbox.

To make this more understandable, lets assume that I have a Table with Client names and the State where they reside and various other information.

The Listbox is based on a Query that list only the Clients residing in a particular State.

On_Open of the Main Form the Listbox is automatically populated with the filtered clients from the Query. When I Click on one of the Clients listed in the Listbox, the information displayed on the Subform is automatically populated/updated with additional data associated with that particular Client. This is based on the AfterUpdate event in the Listbox

O.K., now here's the question.

When I open the Main Form, the Listbox is automatically populated with the filtered data from the Query. However, the Subform indicates data based on the first record in the associated Table.

What I would like is for the Subform to automatically read or be equal to the first record listed in the Listbox not the first record in the Table when the Main Form is opened. By doing so, I can be assured that the data listed in the Subform when the Main Form is opened is relevant to what I set the Query for.

Basically, when the Main Form is opened I would like the Textbox that is located on the Subform to indicate the same Client Name that is listed on the first row of the Listbox.

Any help would be appreciated...
 
Not sure I'm with you, but if I am...

Wouldn't it be better to clear the textbox on open, so when you open the form, nothing is selected in the list box (as happens anyway) and nothing is selected in the text box?

If not, then I guess the way you'd do it would be: In the Open Event, select (highlight) the top item, then call your after update sub. So it's as if the user has opened the form and clicked on the first record.

Personally, I'd use my first method.
AutumnBlues
 
Thanks for the response,

However, since the Listbox is automatically populated in the OnOpen Event of the Main Form, I would like the Textbox on the Subform to match the first line listed in the Listbox not the first Record of the Main Table.

 
I understand that the listbox is populated automatically, but, normally, no item within the listbox would be selected until the user clicks something in there. So if no item is selected in the populated listbox, the textbox should be empty. And it should remain empty until such a time as a listbox item is selected. So to achieve this you would include in the OnOpen event: myTextBox = Null

But if you don't like the idea of an empty textbox, then you need to select the top item in the listbox in the OnOpen event, then call the AfterUpdate sub which you have already.

I think I'm reading you right; I hope I'm not confusing the issue.

AutumnBlues
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top