Results 1 to 10 of 10
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754

    Switchboard Assistance on disabeling a control?

    Hi all,
    I have two issues that i need some assistance on please.

    First Question!
    I am trying to make my Login form option explicit but I really have no clue how to Declare the following.
    Dim msg As (What)
    Dim Style As (What)
    Dim Title As (What)
    Dim Response As (What)

    Code:
    msg = "Your security questions have not been set up. " _
                          & vbCr & "Do you want to set it up now?"
                    Style = vbYesNo + vbQuestion
                    Title = "Set Up Security Question?"
                    Response = MsgBox(msg, Style, Title)
    Second Question!
    On my Login db, I have a switch board and I want to make one of the buttons on the main menu Enabled if user is Admin, and disable if user is User.
    How on earth can i accomplish this? I have read and read and cannot find anything that actually tell me how to do it....\

    With that said, db is attached and thank you for any assistance with these two quesitons.



    Lost
    Dave
    ProfileLogIn.zip

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Well look up MSGBOX and see what those parameters are?

    As for your second question, I just hid any buttons in a switchboard that I did not want a 'user' to see ?

    As the options are in a table for the switchboard, it is just a case of the criteria for the query that populates the switchboard.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    maybe you should encrypt your password field at the very least?
    your questions and answers should not be in the user table but in a related table
    your switchboard form does not allow for user not being logged in. Perhaps a pain for a developer, but can a user open that form withou logging in? Probably should allow for the potential for null in the form load event anyway.
    Simply either DLookup the user level (your UserSecurity field) or create a single record rs with all the details you might need for validation (password, level, questions, etc.) and hide whatever button based on the level. You didn't say which button.

    Forget declaring variables for things like message box parameters - unless maybe there could be several variations for each. If the msgbox will be the same regardless, just provid them in the call. The exception I might make is for the message string, but likely not for button choices, warning levels and the like.

    EDIT
    I am trying to make my Login form option explicit
    Option Explicit has a very specific meaning in Access. I would not use that to describe what you want to do as it's somewhat misleading. At first I thought "that has nothing to do with a form" then I guessed you might be referring to options regarding showing controls or not.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    Thanks Micron
    yes, will encript passwords when i get this finished up. Let them txt for now so one assisting can see. Just sample data and will change later...just for example.
    The button in question is the Admin button on switchboard, sorry i didnt specify.
    I didnt put the null in as you wont be able to get to the forms once implimented so wont be able to open without going through switchboard, wont be any need for it?

    As you know, i am no programmer, i have to make these things and test them out before i put them into action so most of what i do is create and test till i get it the way i want it, then incorporate the final version into my db, which i will add is all most complete. just some minor housekeeping and add a login, and lock it down.

    Would it be better to transfer my macro to vba and then make it maybe easier to work with. I hate macros but found this code long ago and it had macros in it all ready....
    Thanks
    dave
    Thanks

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    First question, Declarations.

    I don't know why such confusing coding is advocated in some quarters.
    MsgBox function is simple:

    Code:
    	Dim Response as integer			
    	Response = Msgbox("Your security questions have not been set up. " _
                          & vbCr & "Do you want to set it up now?", vbYesNo + vbQuestion, "Set Up Security Question?")
            If Response = ....
    With this format you don't need the other 3 declarations.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Well someone who was (might still be) a vip of sorts had this in his signature on some forum:
    Macros are for weenies; code is cool!

    I like to think I wouldn't be as notable but it certainly does reflect my opinion of macros. Then again, I think I can afford to have that opinion. For novices, macros might be all they can manage in the beginning. Somehow I think you're beyond that, or certainly moving in that direction, so yes, I would convert them.

    Have been reviewing stuff in your db & will just copy/paste my notepad notes for your consideration while I go about worrying about what I will have for dinner
    An observation about forum posts in general but maybe yours in particular:

    You dabble in forums long enough and you get a sense that surely certain things were told to a particular member. If I searched your past threads would I not see that
    - you had been told to have Option Explicit at the top of every module - that you should turn it on by default?
    - that multiple declarations on a line each had to be data typed? Your UserName, level variables arer variants. Or is that what you want? Explicit typing is advised even then as it eliminates ambiguity for code reviewers.
    - you should use a naming convention that will virtually eliminate the use of reserved words? ("Last" is a reserved word).
    - you should indent your code blocks, not only for others but for your own troubleshooting as well.
    I don't know; I just have a deja vu feeling about those things and this project. Points taken on the temporary nature of those things you responded to.

    Onward:
    If user tries to "Exit Profile" (not intuitive at all - is that exit the db or just close the login form?). Regardless, if an entry is not valid, you can't cancel.
    I see now that you are doing 4 lookups on the same table. Works, but perhaps a recordset with those 4 fields would be better? Regardless, you are getting the value you need for your posted problem here
    Private Sub CmdUpdate_Click()
    Private Sub CmdLogin_Click()
    so you have it 2x? Easiest might be to just create a TempVar with it (you are already creating one for something else)?

    A Select Case block would be better than a mile long If statement wrt to your questions validation.
    Your login form doesn't close if login successful.

    Other:
    Unless db users are sharing a Windows login (e.g. one pc in an office/school/club environment that could have anyone logged in at any point of use) then I'm not a fan of password admin and all the junk around it. If it's a one db user/one Windows login, I'd just lookup their W login from the table. If it's not there, they don't get in, so no forgetting/resetting pwd's, no code for it, no calls for lost password help, and all the other bother around it. OK, you have to add members, but that's usually a requirement for db's that need passwords/user profiles anyway.

    That's it until after din-din.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    Thank you davegri
    I tried different senarios like this but didnt work. Will give this a try with complete confidence!
    Thanks\
    Dave...

    Someone wrote that for me a long time ago... Not even sure who now but i think it was from one of his db's and he just shared it withme when i was seeking how to do a long on form.

  8. #8
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    Have a good dinner and thanks Micron....
    I can still make changes to it so no harm done yet.
    And keep in mind, just a few users will ever use this as its a personal / family thing
    Thanks again

  9. #9
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    ProfileLogIn (2).zip

    Hi all,
    OK, I uploaded a new db as I made changes....
    I removed switch board, Added Main Menu form,
    Was able to get UserID on to it and Security Level so that is good.

    On the form (frmMainMenu) I have a button called Change Password
    I put the following code behind it,

    Code:
    Private Sub CmdChangePsw_Click()
    DoCmd.OpenForm "frmChangePassword"
    Forms!frmChangePassword!UserID = UserID
    End Sub
    And am now getting error (Runtime 2448)
    which states I cant assign a value to this?

    What I am seeking it to open that form with the value of the UserID from my MainMenu.
    I dont understand why it wont let me assign that as you can (or will be in near future only to access this form when logged in and on MainMenu)
    and I only want to allow the logged in user to open their info, not all.
    Not sure what to do here folks?

    Thanks
    Dave

  10. #10
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    No bother,
    I found a solution that seems to work just dandy!

    DoCmd.OpenForm "frmChangePassword", , , "UserID = " & UserID

    Thanks all,
    Dave

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Switchboard Main Menu assistance
    By d9pierce1 in forum Forms
    Replies: 7
    Last Post: 09-16-2020, 04:10 AM
  2. Disabeling the Before Update Event on Edit
    By d9pierce1 in forum Programming
    Replies: 26
    Last Post: 12-05-2018, 02:07 PM
  3. Replies: 6
    Last Post: 08-13-2018, 11:12 AM
  4. Replies: 1
    Last Post: 09-27-2013, 03:53 PM
  5. Replies: 7
    Last Post: 09-13-2011, 01:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums