Reputation: 135
Using MS Access 2010, I need to generate the NavigationButtons of a Navigation Control at Form_Load time (or similar.) (To be clear, this isn't a tab control nor a ribbon nor a menu.) The use case is, there are a variable number of forms and reports that need to be added to the Navigation Control at run time. We won't know how exactly many, or which, forms will need to be added, so they need to be added dynamically in code. Is this possible with a Navigation Control? I can find no reference to achieving this.
My instinct was something like:
Me.NavigationControl0.AddButton("Report X")
But no such 'AddButton' method exists... or any other combination of machinations or configurations that will do the job.
Upvotes: 0
Views: 2305
Reputation: 27634
You need CreateControl
.
Note that the form must be open in Design view to use this. You can find many examples on the net, e.g. here.
If this doesn't work for you, and if you have an upper limit of needed buttons, you can create the maximum number manually, and at runtime hide as many as you don't need. Making buttons .Visible=False
and changing their .Caption
can be done in Form view.
Upvotes: 2