Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 8th, 2003, 07:55 PM
Authorized User
 
Join Date: Aug 2003
Location: , , Australia.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Frame Switchboard and Listbox Report

Hi guys,

Not to follow the crowd :), but I also had difficulty in creating a switchboard. I want to create to create a switchboard for my application, in which that switchboard would behave like a framed website. So everytime a users click the main menu A on the top, the sub menu details would appear below it (in the middle). The same thing when main menu B was clicked, its sub menu details  would appear below it ( in the middle), replacing the sub menu details for main menu A. Is it possible for VBA?

The second problem was populating a list of report on the listbox according to certain main menu. I can populate the list of all reports within the listbox...with this VBA coding:

'lstReports was the listbox name
Private Sub Form_Load()
    Dim objAO As AccessObject
    Dim objCP As Object
    Dim strValues As String

    Set objCP = Application.CurrentProject
    lstReports.RowSourceType = "Value List"

    For Each objAO In objCP.AllReports
        Me.lstReports.AddItem (objAO.Name)
    Next objAO
End Sub

Private Sub ProcessReport(intAction As Integer)
    If Not IsNull(lstReports) Then
        DoCmd.OpenReport lstReports, intAction
    End If
End Sub

But it would confused the users as they would see too many reports....So I want to list only certain reports related to the main menu....I tried to just put the reports name on this line:

Me.lstReports.AddItem ("Report A") & ";"
Me.lstReports.AddItem ("Report B")

Unfortunately, it didn't work like what I want.

Anyone can help me with these 2 problems? I am still learning about VBA.

Million thanks in advanced.

Cheers,

Fehrer
Reply With Quote
  #2 (permalink)  
Old September 8th, 2003, 10:56 PM
Registered User
 
Join Date: Sep 2003
Location: Lisboa, Lisboa, Portugal.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Fehrer:

If you have the associated reports with a specific prefix, lets say
rptMenu or rptMlist or whatever to let you identify that a group of reports belongs to the menu, will be easy to select them.
Supose the following names
1.rptMenuList
2.rptMenuTxt
3.rptMenuCbo


Code:
For Each objAO In objCP.AllReports
        If InStr(objAO.Name,"Menu") then 
            Me.lstReports.AddItem (objAO.Name)
         End if
Next objAO
good luck

Estuardo




Reply With Quote
  #3 (permalink)  
Old September 9th, 2003, 02:40 AM
Authorized User
 
Join Date: Aug 2003
Location: , , Australia.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Estuardo,

Thanks for ur advice. I tried to modify my coding based on yours, but it didn't work, message box saying Expected array.

Supposed the available reports on Reports objects are
1.rptMenuList
2.rptMenuTxt
3.rptMenuCbo

The ones that I want to populate within lstReport listbox in frm_CustomersMenu are rptMenuList dan rptMenuCbo.
Here is my VBA coding...

Private Sub Form_Load()
    Dim objAO As AccessObject
    Dim objCP As Object
    Dim intStr As String

    intStr = Array("rptMenuList", "rptMenuCbo")

    Set objCP = Application.CurrentProject
    lstReports.RowSourceType = "Value List"

    For Each objAO In objCP.AllReports
        If intStr(objAO.Name, "rptMenuList") Then
            Me.lstReports.AddItem (objAO.Name)
        End If
        If intStr(objAO.Name, "rptMenuCbo") Then
            Me.lstReports.AddItem (objAO.Name)
        End If
    Next objAO
End Sub

Private Sub ProcessReport(intAction As Integer)
    If Not IsNull(lstReports) Then
        DoCmd.OpenReport lstReports, intAction
    End If
End Sub



Many thanks.

Cheers,

Fehrer
Reply With Quote
  #4 (permalink)  
Old September 9th, 2003, 07:10 AM
Friend of Wrox
Points: 3,947, Level: 26
Points: 3,947, Level: 26 Points: 3,947, Level: 26 Points: 3,947, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,150
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by Fehrer
I want to create to create a switchboard for my application, in which that switchboard would behave like a framed website. So everytime a users click the main menu A on the top, the sub menu details would appear below it (in the middle).
Fehrer, that is possible to do. You would open main form that had a subform on it. Size the subform any way you want. Then create many subforms that take up the exact same size as the space allowed on the main form. When the user clicks any button on the main form then you change the subform's source object to any of the save subforms you created.

For example, on the main form you have three buttons: cmdButtonA, cmdButtonB, and cmdButtonC. You created three subforms: sfrA, sfrB, sfrC. Then on each of the button's On Click event you put this:
Code:
Public Sub cmdButtonA_Click()

    Me.sfrMysubform.SourceObject = "sfrA"

End Sub
Write the same On Click event for buttons B & C, too; however, substitute the A with B and C, respectively.




Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #5 (permalink)  
Old September 9th, 2003, 07:54 AM
Authorized User
 
Join Date: Aug 2003
Location: , , Australia.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by SerranoG

For example, on the main form you have three buttons:  cmdButtonA, cmdButtonB, and cmdButtonC.  You created three subforms: sfrA, sfrB, sfrC.  Then on each of the button's On Click event you put this:
[code]Public Sub cmdButtonA_Click()

    Me.sfrMysubform.SourceObject = "sfrA"
Hi Serano,

Thanks a lot for the advise. Very clear explanation and logical. I have tried it, but I confused with sfrMysubform word, what does it refer to? Is it the main form name, method or properties of the subform? When I click the button for subform A (for example), message box saying "Method or data member not found" comes up. Even after I changed sfrMysubform with my main form name, the same message still appear.

Regards,

Fehrer


Reply With Quote
  #6 (permalink)  
Old September 9th, 2003, 08:00 AM
Friend of Wrox
Points: 3,947, Level: 26
Points: 3,947, Level: 26 Points: 3,947, Level: 26 Points: 3,947, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,150
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by Fehrer
I confused with sfrMysubform word, what does it refer to? Is it the main form name, method or properties of the subform? When I click the button for subform A (for example), message box saying "Method or data member not found" comes up. Even after I changed sfrMysubform with my main form name, the same message still appear.
Sorry about that... sfrMysubform is just a fake name I used to call your SUBform (not the main form) because I didn't know its real name. Substitute the name of your subform there.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #7 (permalink)  
Old September 9th, 2003, 08:05 AM
Friend of Wrox
Points: 3,947, Level: 26
Points: 3,947, Level: 26 Points: 3,947, Level: 26 Points: 3,947, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,150
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by SerranoG
Substitute the name of your subform there.
Let me clarify that. You have a main form with a name. I'll make one up for now: frmMyMainForm. Suppose you have three subforms: sfrA, sfrB, and sfrC. On the main form you have a control object where your subform will sit. The name of this control object is (say) sfrMysubform. The source object for sfrMysubform will be sfrA, sfrB, or sfrC depending on which button the user clicks.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #8 (permalink)  
Old September 9th, 2003, 08:17 AM
Authorized User
 
Join Date: Aug 2003
Location: , , Australia.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Serano,

Thx for your patience. I understand ur point, but I don't know what u mean by control object. Even, I can't find it on the properties. Which one the control object is?

Cheers,

Fehrer

Reply With Quote
  #9 (permalink)  
Old September 9th, 2003, 08:26 AM
Friend of Wrox
Points: 3,947, Level: 26
Points: 3,947, Level: 26 Points: 3,947, Level: 26 Points: 3,947, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,150
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by Fehrer
Thx for your patience. I understand ur point, but I don't know what u mean by control object. Even, I can't find it on the properties. Which one the control object is?
Everything you place on a form is called a control object: a button, a list box, a combo box, a text box, a subform, an option group, etc.

When you place a subform on a form, you're placing a control object on the form. Usually, the wizard will turn on and ask you which form you would like use as the source object for the subform. You can say it's (in my example) sfrA. When the user clicks Button A, B, or C, the On Click event will change the source object to something else (sfrB or sfrC, for example).


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #10 (permalink)  
Old September 9th, 2003, 08:38 AM
Authorized User
 
Join Date: Aug 2003
Location: , , Australia.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Serano,

Oh my God, :). OK, got it, thanks, very much appreciated. I have done what u said, with this event click for each button,

Public Sub cmdOrdersMenuSB_Click()
    Me.sfrMysubform1.SourceObject = "Orders_SubForm"
End Sub


Public Sub cmdCustomersMenuSB_Click()
    Me.sfrMysubform.SourceObject = "Customers_SubForm"
End Sub

However, when I click both the button, the subform did not appear. It only show the last subform created. Anything that I missed?

Thanks
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
parsing form data from frame to other frame audio-catalyst Classic ASP Basics 5 January 3rd, 2006 01:57 PM
Switchboard ?s JeffGirard Access 1 September 15th, 2005 02:52 AM
Call right frame Page_Load event from left frame. ochanarachel Classic ASP Basics 0 January 28th, 2005 04:13 AM
Printing Report in Bottom Frame itHighway Classic ASP Basics 2 December 29th, 2004 07:31 PM
How to use use ListBox in SQL Report abhiinbwir ADO.NET 0 July 13th, 2004 06:33 AM



All times are GMT -4. The time now is 09:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.