Binding a List Box

imright

Registered User.
Local time
Today, 00:36
Joined
Jun 27, 2008
Messages
30
I have a list box of all open forms on my startup page. How do I do set it up so that I can click on the form number to open that form? Access Help says to go into properties under data control/source and input the source. I've tried that but probably input something wrong. The form is controlled by a Query so I put the Query name in.
FYI, I'm using Access 2003 and completely ignorant on VBA:eek:
 
I have to say that your post is contradictory!

First you say

"I have a list box of all open forms on my startup page."

Then you say

"How do I do set it up so that I can click on the form number to open that form?"

And what form number are you referring to?

That aside, the best way to open forms either from a listbox or combobox (both use the same syntax) is to:

Set the listbox/combobox Row Source Type to Table/Query

Set the Row Source to:

Code:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND
(MSysObjects.Type)=-32768 ORDER BY MSysObjects.Name;
This will automatically list all forms in the database without you ever having to update the list when new forms are added.

Then add this code to the box's AfterUpdate event

Code:
Private Sub ListBoxName_AfterUpdate()
 DoCmd.OpenForm ListBoxName.Value
End Sub

Now, when you click on a selection in the listbpx/combobox, the form will open.
 
I couldn't get it to work, I see Name in brackets so I assume that I would put the form name in there but what about all the places that same name?
Sorry, this must seem like a pretty ignorant question but I'm not a programmer and no nothing about VBA.
 
My boss asked me to create a database for collecting certain information and creating reports which I've done, I'm just trying to make it user friendly plus I enjoy learning new things. I know a little more than the basics of Access but have no experience in VBA which makes what I'm trying to do very limiting. That being said I've had plenty of help on this forum so I march on!
 
You don't replace anything in this code:

Code:
[CODE]SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND
(MSysObjects.Type)=-32768 ORDER BY MSysObjects.Name;
[/CODE]
You simply copy and paste it in the RowSource property of the combobox.
 

Users who are viewing this thread

Back
Top Bottom