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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListIndex Property

Status
Not open for further replies.

FoxProProgrammer

Programmer
Apr 26, 2002
967
US
I am developing a form with a Tab control. One of the tabs has a combo box. I want to initialize the item selected in the combo box when the user selects that tab. I initialize the selected row in the combo box in the Tab Change event with the following code.

ComboBox.ListIndex = 0

This works fine as long as I click on any tab other than the tab that contains the combo box. For example, if I change the tab and come back to the tab with the combo box it works fine. The first row is selected like I want. However, if I click on the tab that contains the combo box when that tab is already displayed, I get the following error:

Run-time error '7777':

You've used the ListIndex property incorrectly.

The Help isn't enabled on the error dialog window and F1 doesn't run help either. Does anyone know what's causing this? If I have to I can save the last tab pressed and enclose the ListIndex code in an If structure that bypasses the statement if the current tab is the same as the last tab. That just seems convoluted if there's a logical reason why this error occurs.

Thanks!

dz
 
dz -

Interesting problem. I assume your combo box is not bound to an underlying field. When I set this up I observed a different problem. Instead of getting the '7777' error while re-clicking on the tab with the combo box, I rec'd the error while clicking on the other tabs, i.e., when I clicked on Page 1, where the combo box is located, I obtained the desired index for the combo box; irregardless of what record I was located on in the underlying recordset (Form bound to a query). I also noticed that when an unbound combo box has no selected value it's Index is set to "-1".

Unlike in your case, when I clicked on Page 2, 3 or 0, I rec'd the '7777' error. Repetitive clicking on Page 1 (combo page) resulted in nothing happening (the first click opening up that page and setting the combo ListIndex to 0). Not having the error message on repetitive clicks on Page 1 I just put the following code on the OnChange event:

Private Sub TabCtl0_Change()
If TabCtl0 = 1 Then
Combo.ListIndex = 0
Exit Sub
End If
End Sub

I did not set this up with a "bound field" in the combo box. dz - your earlier treatment of the parsing question was excellent.
 
Thanks for your reply, Isadore. It is really strange that this acts differently on your system. You are right that the combo box is unbound. I wish that I knew why Access behaved differently on different systems. I suppose it could have something to do with the way the environment is set up, but I don't really know. Do you have any idea why it acts differently on your system than mine?

I saw another discrepancy in how Access works on two computers the other day. Somebody on this forum asked how to disable the close (x) on Access to prevent his users from exiting Access when working on a form. I suggested that he make the form modal, and two people replied that they could still close Access even when the form was modal. It doesn't work that way on my system. When a modal form is open, I must close that form before I can click anywhere outside the form. The computer beeps if I click outside the form. Maybe I should go back to FoxPro! <grin>

dz
 
I hear ya Fox. I've encountered two problems this week that work beautifully on other systems but not on mine, q.v.,

The Filecopy Action

Filecopy &quot;C:\MyFile.txt&quot;, &quot;C:\NewFolder\MyFile.txt&quot;

...doesn't fly on mine (Access 2000/Presario 2700) and when working on a multi-select list box...

List1.AddItem List2.List(i)....

...AddItem was nowhere to be found in my vbc...??????

I rec'd a decent response on the Filecopy (a few pages back, about 2 days) and need to follow through on the advice...yes, these discrepancies are very strange indeed.

 
jebry on another post pointed out that AddItem wasn't in vba, only vb...looked later in the object browser to try and find it and of course it wasn't there...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top