By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,153 Members | 2,581 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,153 IT Pros & Developers. It's quick & easy.

combo that looks up forms to load

daniel aristidou
100+
P: 491
Hi i have created all my forms for my database and every thing runs smooth but i would like to have a login form where i can have a combo box that scrolls down showing an option of forms. the thing is i would like it to show only specific forms... or have a nother master combo box which cascade updates the other to select the forms related to that topic. i have seen this before where u click on a command button and it loads the form that is selected in the combo box. thanks in advance for the help.!
p.s Im not very familiar with visual basic code but should be ok providing someone runs through the steps fully with me. thanks again in advance for helping.
Sep 5 '07 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,383
Hi i have created all my forms for my database and every thing runs smooth but i would like to have a login form where i can have a combo box that scrolls down showing an option of forms. the thing is i would like it to show only specific forms... or have a nother master combo box which cascade updates the other to select the forms related to that topic. i have seen this before where u click on a command button and it loads the form that is selected in the combo box. thanks in advance for the help.!
p.s Im not very familiar with visual basic code but should be ok providing someone runs through the steps fully with me. thanks again in advance for helping.
This tutorial will help you set up the combo boxes.

As for opening the form, you can use DoCmd.OpenForm cbo_FormName
Sep 5 '07 #2

Jim Doherty
Expert 100+
P: 897
Hi i have created all my forms for my database and every thing runs smooth but i would like to have a login form where i can have a combo box that scrolls down showing an option of forms. the thing is i would like it to show only specific forms... or have a nother master combo box which cascade updates the other to select the forms related to that topic. i have seen this before where u click on a command button and it loads the form that is selected in the combo box. thanks in advance for the help.!
p.s Im not very familiar with visual basic code but should be ok providing someone runs through the steps fully with me. thanks again in advance for helping.
The easiest method for you to keep a handle on this is to insert into a table of your own a list of your database forms sitting 'independant' of Access's own method for storing its objects.

You can then assign control elements by creating extra fields in that table where you can then control and store what 'does' and 'does not' happen for instance a field might be called SHOW as a simple Yes/No field tickbox shall we say. You would then base your listing of forms in any dropdown on the contents of this table where Show=True or Show =False.

You are going to have flexibility on this because you can add extra fields to your table to add extra controlling or restrictive elements that you might seek and call back this list in an SQL statement using relevant criteria

ie: "SELECT NameOfForm FROM tblMyListOfForms WHERE Show=TRUE"

and for a listbox as in your case you might want to set the rowsource in much the same way

Depending on your version of Access below is an SQL statement that will retrieve for you a List of Access forms from its MsysObjects table. If you use this in the query Window like So...

Expand|Select|Wrap|Line Numbers
  1. SELECT MSysObjects.Name AS NameOfForm INTO tblMyListOfFormNames
  2. FROM MSysObjects
  3. WHERE (((MSysObjects.Type)=-32768))
  4. ORDER BY MSysObjects.Name;
You will have 'automatically created' for you an independant table as mentioned visible in the Access window that you can work with easier than having to potentially hardcode everything. The only downside to this technique is that you have te remember.... it is an independant table as such so if you create another form it will not obviously be in the table automatically. (Unless of course you find that the technique works so well in your circumstances that you are happy to employ simple methods keep this table updated and synchronised to the current objects in the database. (which you could raise as another thread if you have problems but I suspect you won't) It is a matter for you.

In terms of your extra requirement ie: the interdependant combo boxes this is a regular feature raised often and quite easily sorted out. I'd go with trying out the above firstly and then return when you need to determine your datavalues of one combo based on another. you will get answers on this quite easily in my absence from others. unless I pick up the thread again when I will be happy to assist you.

Hope this helps

Jim
Sep 5 '07 #3

daniel aristidou
100+
P: 491
Hi guys You have both been Great help !!!!! Superb work thanks alot , i found the easiest way was to create multiple tables and combo boxes(a combo box for each tbl) instead of using cascade updating boxes. You have been great help, and i hope anyone else with the same problem will look here and figure it out as easily as i did with the information you provided me with.~!!!!
Sep 5 '07 #4

Rabbit
Expert Mod 10K+
P: 12,383
Good Luck.
Sep 5 '07 #5

Denburt
Expert 100+
P: 1,356
This one may be a bit more complicated but I use this to show certain sub-reports in a listbox I can then choose which sub-reports I want to show. It is very similar to what you were describing. Simply paste the following in a module and in the rowsourcetype of the combobox enter "GetForms" I don't even use the rowsource. I use the first three letters SHW to show the ones I want to see in the listbox.


Expand|Select|Wrap|Line Numbers
  1. Function GetForms(Fld As Control, id As Variant, row As Variant, col As Variant, Code As Variant) As Variant
  2.   Static dbs() As String, Entries As Integer
  3.   Dim ReturnVal As Variant
  4.   Dim con As Container
  5.   Dim db As Database
  6.   Dim doc As Document
  7.   Dim m
  8.   Set db = CurrentDb
  9.     ReturnVal = Null
  10.     Select Case Code
  11.         Case acLBInitialize
  12.             Entries = 0
  13.   Set con = db.Containers("Forms")
  14. redim preserve dbs(con.Documents.count)
  15.     For Each doc In con.Documents
  16.         If Left(doc.Name, 3) = "SHW" Then
  17.                 dbs(Entries) = Right(doc.Name, Len(doc.Name) - 3) 
  18.         End If
  19.             Entries = Entries + 1
  20.         End If
  21.     Next doc
  22.                 ReturnVal = Entries
  23.         Case acLBOpen
  24.             ReturnVal = Timer
  25.         Case acLBGetRowCount
  26.             ReturnVal = Entries
  27.         Case acLBGetColumnCount
  28.             ReturnVal = 1
  29.         Case acLBGetColumnWidth
  30.             ReturnVal = -1
  31.         Case acLBGetValue
  32.             ReturnVal = dbs(row)
  33. Case acLBEnd
  34.             Erase dbs
  35.     End Select
  36.     GetForms = ReturnVal
  37.     End Function
  38.  
Sep 5 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.