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

List Click

Status
Not open for further replies.

Domino2

Technical User
Jun 8, 2008
475
GB
I am trying to call a listbox on a subform to be clicked from a mainform.

Forms!Form2!LocationsSubform.Form.List10.SetFocus
Forms!Form2!LocationsSubform.Form.List10.ListIndex = 0
Forms!Form2!LocationsSubform.Form.List10_Click

Can someone tell me whats wrong, thanks
 
How are ya Domino2 . . .

The problem is that the [blue]List10_Click[/blue] event is [blue]Private[/blue]. Meaning its only available to the code module of [blue]LocationsSubform[/blue]. Whats needed is a [blue]public[/blue] sub extension that calls [blue]List10_Click[/blue]. So ... in the code module of v[blue]LocationsSubform[/blue], copy/paste the following:
Code:
[blue][purple][b]Public[/b][/purple] Sub List10Ext_Click()
   List10_Click
End Sub[/blue]
Modifying the code for your [blue]List10_Click[/blue] event we have:
Code:
[blue]   Dim sfrm As Form
   
   Set sfrm = [LocationsSubform].Form
   
   sfrm.List10.ListIndex = 0
   sfrm.List10Ext_Click
   
   Set sfrm = Nothing[/blue]
Thats it ... perform your testing.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 

BTW: do not change your [blue]LocationsSubform[/blue] event to [blue]Public![/blue] ... this is a no no.

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hi, Many thanks however I get an error 2465 - Application defined or Object - defined error.

I can see list10 gets highlighted, but the code breaks on the line sfrm.List10Ext_Click

Any ideas, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top