Solved

Switchboard wizard extra buttons

Posted on 2003-11-18
12
434 Views
Last Modified: 2011-08-18
I used the wizard to make the switchboard and when you go into design mode it has loads of buttons. I have deleted all of the ones that I don't want and now my program doesnt work. Why?
0
Comment
Question by:wjdashwood
  • 4
  • 2
  • 2
  • +4
12 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9770741
the buttons that you REMOVED are in fact REQUIRED by the switchboard, for it to function properly.  When the Number of buttons that are present on the form in design mode (max is 8) is greater than the number NEEDED on any given Switchboard screen, then the code will automatically make the un-needed buttons INVISIBLE.  DO NOT remove the buttons.  In fact, having deleted them, it is NOT simply enough to recreate the buttons, on the Switchboard form, in design mode.  You will need to completely delete the ENTIRE SWITCHBOARD (form And Table), and start over again, from scratch.

Why did you feel it necessary to delete the buttons in the first place.  Dis it not occur to you that they just might be there for a reason?  Believe me, the wizard is a LOT SMARTER than you are, when it comes to building a Switchboard (I have been programming, professionally, for more than 40 years, and using Visual Basic for alsmot 10 years, so I can absolutely guarantee that the Switchboard Wizard is a VERY clever piece of code, and is well beyond the understanding of many, if not MOST, of the Users of Access.

AW

0
 
LVL 17

Expert Comment

by:walterecook
ID: 9770908
AW is right (if not a little crabby this morning.  :)  )

Well the reason that it no longer works it because the code behind the switchboard loops through the names of the buttons (I dont remember exactly but basically...) It deals with button1, button2, button3, etc.  When you deleted some of them the loop tried to find "button8", couldn't, and died.
If you try to put them back, watch the names of the new objects.
Or recreate it

Good luck
walt
0
 

Author Comment

by:wjdashwood
ID: 9770920
I know it makes them invisible and my program does NOT use them, there is one part of the code that needs to be removed so that it will not try to use them, I have done it once before but can't remember how now. I have other buttons on the switchboard which I have created. All I need the switchboard for is to have the ability to make it appear on startup. I have many other things on the switchboard and these extra buttons are getting in the way, I will not use them so I don't see why they have to be there.
The wizards may be very clever, as they are in most programs but in my experience if you don't want to use them for exactly what they are designed for then there is unecessary code included as it must work for many different solutions. It is usually possible to remove this code and get it working how you need it.
0
 

Author Comment

by:wjdashwood
ID: 9770939
I didn't want any buttons. I just want to use it for the startup. I can put my own buttons on.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9771208
I do EXACTLY this with an application that I wrote a while back:

1) I added a form_level BOOLEAN variable, LoggedIn

then in the Form_Current Event Handler:

Private Sub Form_Current()
    If LoggedIN Then
        Me.Caption = Nz(Me![ItemText], "")
        FillOptions ActiveOffice
    End If
End Sub

then in the Click Event of the cmdLogin button:

Private Sub cmdLogin_Click()
    Dim db As Database
    Dim strSQL As String
    Dim rsUser As Recordset
    Dim qdf As QueryDef
   
    Screen.MousePointer = 11 ' hourglass ==> Busy
   
    strSQL = "Select * from tblUser where UserName = '" & txtUser & "'" & _
        " AND Password = '" & Encrypt(txtPassword) & "'"
    Set db = CurrentDb
    Set rsUser = db.OpenRecordset(strSQL)

    If Not rsUser.EOF Then
        mUserID = rsUser("UserID")
        If txtPassword = "password" Then
           
            MsgBox "You MUST change your password from the INITIAL DEAFULT password", vbOKOnly
            SetNewPassword
            txtPassword.SetFocus
        Else
            txtPassword = ""
            LoggedIN = True
            cmdPassword.Visible = True
            If rsUser.Fields("Division") <> "SAIC" And rsUser.Fields("Division") <> "XOEK" Then
                db.QueryDefs.Delete "qryActiveOffice"
                Set qdf = db.CreateQueryDef("qryActiveOffice")
                qdf.SQL = "SELECT tblDivision.DivID, tblDirectorate.DirID, tblDivision.Division, " & _
                "tblDirectorate.Directorate FROM tblDirectorate INNER JOIN tblDivision ON tblDirectorate.DirID = tblDivision.DirectorateID" & _
                " where tblDirectorate.Directorate = '" & rsUser("Division") & "'"
                qdf.Close
                mActive = False
               
            Else
                db.QueryDefs.Delete "qryActiveOffice"
                Set qdf = db.CreateQueryDef("qryActiveOffice")
                qdf.SQL = "SELECT tblDivision.DivID, tblDirectorate.DirID, tblDivision.Division, " & _
                "tblDirectorate.Directorate FROM tblDirectorate INNER JOIN tblDivision ON tblDirectorate.DirID = tblDivision.DirectorateID"
                qdf.Close
                mActive = True
                If rsUser.Fields("Division") = "XOEK" Then
                    mActive = False
                End If
            End If
            ActiveOffice = rsUser("Division")
            FillOptions ActiveOffice
        End If
    Else
        MsgBox "Invalid UserName and/or password", vbCritical
        txtUser.SetFocus
    End If
    Screen.MousePointer = 0 ' Normal
End Sub


don't worry about all the extraneous details, suffice it to saythat  the LoggiedIn value is set to True, to allow the Form_Current method to then turn ON the relevant buttons of the SwitchBoard.

No need to change any of the SwitchBoard button code, no need to remove any of the Switchboard buttons.

AW
0
 
LVL 77

Expert Comment

by:peter57r
ID: 9771215
Then don't use a switchboard.
Just design your own form and put your own buttons on it.
Switchbords are a liability when converting between versions anyway.


Pete
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9771236
in particular, notice that when the LoogedIN is set to true, then FillOptions is called, which is the Switchboard routine that turns on the relevant buttons, for the Main switchboard.  In the specific case here, I have made modifications to the code supplied by the Wizard, because which Buttons are available to a User is based on the Office to which that user belongs.  But in your case, you simply call the FillOptions sub on the Switchboard from, exactly as if the code that the wizard builds in the default Form_Current event hade been called.

AW
0
 
LVL 2

Expert Comment

by:jack49a
ID: 9771243
It sounds like you don't want the switchboard.  Design your own start-up form and then under tools/statrup select that form to be the one you see at startup.

Jack
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9771269
and yes, walterecook, I was a 'bit crabby' this morning.  1) I didn't sleep all that well last night, 2) traffic was a B***H, and 3) I get frustrated with people coming here to ask us to clean up messes that they created because they haven't got a clue what they are doing, but feel compelled to do it anyway.  It like a sign that was seen in a lab:

Alles Buttones es Nicht Fur Das FingerPoken and Knobgetwiddlen.

AW
0
 
LVL 17

Expert Comment

by:walterecook
ID: 9771288
AW: you have the right, it just surprised me a little because it's not really your nature. :)
Pete: I left you some points.  Go pick them up
wjdash: have they gotten you all straightened out?

Walt
0
 
LVL 32

Expert Comment

by:jadedata
ID: 9771672
wow,... I'm glad I didn't remove that switchboard button.... :)
0
 
LVL 7

Accepted Solution

by:
donpricejr earned 500 total points
ID: 9773843
Create a new form. In addition to that form you may have public functions which call open: frm, rpt, etc. Therefore, you may call the same function throughout the app. without the need to duplicate code and manage all of the code if a name changes. This will prevent you to either keep copious notes on what it affected and what is not by a simple change in either tbl structure, naming convention, what-not.

...Basically, we are all spoiled using VBA (VB, any scripting language, too) because it is event-driven and so we don't think to [modularize] everything and so sometimes we need to re-think an approach to a common subject matter, as you will see in "real" or lower languages.

Sorry for the theory, but I think some experts tend to do things the hard way (not that they are not great, or even remarkable concepts), they are just using a sledge hammer for a nail 1/8" in diameter...

Best of luck.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now