User Level Security Wizard

Hmm, makes no sense. Please post the code in the On_Load event as you have it now.
 
This is the On-Load for the switchboard:

Option Compare Database

Private Sub Form_Load()
On Error Resume Next

Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim myQuery As String

myQuery = "SELECT * FROM tblUsers WHERE uNetworkID = '" & Environ("UserName") & "'"

Set db = CurrentDb()
Set rst = db.OpenRecordset(myQuery, dbOpenDynaset, dbSeeChanges)

If Not rst.BOF And Not rst.EOF Then
rst.Edit
rst.Fields("uLogonCount") = rst.Fields("uLogonCount") + 1
rst.Fields("uLastLogon") = Now()
rst.Update
Me.txtSecurityID = rst.Fields("uSecurityID")
Me.txtOverride = rst.Fields("uSpecialPermissions")
Me.txtUserID = rst.Fields("uUserID")
Me.txtDelete = rst.Fields("uDelete")
Me.txtPassword = rst.Fields("uPassword")
DoEvents
Else
DoCmd.OpenForm "frmNewUser", acNormal, , , , acWindowNormal
Me.Dirty = False
Me.Visible = False

Do Until Me.Tag = "Continue"
DoEvents
Loop
End If

Set rst = Nothing
db.Close
Set db = Nothing

If IsDeveloper Then
ChangeProperty "AllowBypassKey", dbBoolean, True
Else
ChangeProperty "AllowBypassKey", dbBoolean, False
End If

Form_Load_Exit:
Exit Sub
End Sub
 
Well, aside from confirming the spelling of the field names, I am going to need to see the file. Can you upload a stripped down copy?
 
I got and will look at as soon as I finish my conference calls (or maybe in between them). Just didn't want you to think I forgot you! :)
 
Got no error. Opened Switchboard, New User form opened, filled in my info and it went where it was supposed to. So what are you doing differently? I did notice your SecurityID control is visible, the one in the example is not nor should you fill in any data. Could that be it?
 
I'm not adding anything to the SecurityID. Just forgot to hide it when I readded it.

I put in my login details in that same stripped down version and hit continue and nothing happens. The frmNewUser form won't even pop up at the start. I get the errors when I open the frmPlansSearchPage.
 
Hmm, well when I hit continue it went right to the Switchboard. What version of Access are you using?
 
running 2016. Would it be something different in my Access Options?
 
Well, I just opened frmPlansSearchPage and that On_Load code does not go there. It is only for the Switchboard so that explains that error. Also,

1. You also did not include the the Module for ConcatRelated
2. you did not change the control names in the below line to match yours...
Code:
Call LogDeletion(Me.txtOrderID, "frmOrders", "Order " & Me.txtOrderID & " has been successfully deleted!")
3. The Control for the uSecurityID has not been named txtSecurityID
4. You did not include the code for fncLockUnlockControls Me, True
5. the Function for IsDeveloper() needs to be in a separate Module along with ChangeProperty

All the missing Functions can be found by clicking the links on my website. I know there are a few steps there but you must take care to follow each one, no shortcuts when implementing this.
 
Oh I see the links now for the Concat etc. This code is a huge learning curve for me!

That list will keep me busy!!

Thank you so much taking a look!!!!!:D
 
I thought I would go back through the New User Form Procedure and check I have done everything. I get to step 5 and nothing happens once I have entered my details and click continue.

with the uSecurity Field on the new user form, I have the Name as txtSecurityID and the control source as uSecurityID. Is that right?
 
DId you change frmMainMenu to Switchboard (the anme of our Form)?
 
Yes, I did.

Forms(Switchboard).Tag = "Continue" 'frmMainMenu change to the name of your Main Menu/Switchboard/Navigation Form
 
Did you clean the Table? You don't open the New User to test if your information is still in the table. If that's not it than I need a copy again. I am getting ready for another conference call... don't get anxious if I don't answer right away.
 
Yes, I have been clearing the table before testing it. The user form still doesn't pop up when I open the database, nor does it go to the switchboard once I click continue.

I have also included a copy of my settings. Is something different there?:confused:

Thank you
 

Attachments

So, there are a few things wrong with you will find if you put...

Code:
Option Compare Database
Option Explicit

... at the top of EVERY Module, including the ones behind the Forms.

-You need to remove Continue from the Tag Property of the Switchboard. The code will handle that.

-You moved the Functions I mentioned to a Module but you did not remove them from behind the Forms (the above item would have caught that which is why it is so important to put to have those at the top).

-You copied and pasted this line incorrectly...
Code:
strSQL = "INSERT INTO tblUsers ( uNetworkID, uFirstName, uLastName, ueMail, uLastLogon, uLogonCount, uSecurityID, uActive )" & _
     " Values ('" & Environ("UserName") & "' , '" & Me.txtFirstName & "', '" & Me.txtLastName & "', '" & Me.txteMail & "', Now(), 1, 9, True"

Because when you did it ended up on one line and was erroring out but it never told you that because you did not have the two lines at the top. So the code just failed with an obscure message about a Form which had nothing to do with what was really wrong.

Oh, and set the Switchboard to open when Access opens under Options. That should cover it.
 
WOW :D
I'm getting excited!! It looks like it is almost working!!
I did those things and then I get the attached messages. I get this regardless of whether the word continue is in the Tag property of the Switchboard or not.
 

Attachments

  • Screenshot of error.jpg
    Screenshot of error.jpg
    73.7 KB · Views: 77
Hmm, it might not like Environ("UserName"), might need to add that to a Module, so put the below in one of your Modules...

Code:
Public Function GetUserID() As String
  GetUserID = Environ("Username")
End Function

Then change that line to...

Code:
strSQL = "INSERT INTO tblUsers ( uNetworkID, uFirstName, uLastName, ueMail, uLastLogon, uLogonCount, uActive )" & _
            " SELECT GetUserID(), '" & Me.txtFirstName & "', '" & Me.txtLastName & "', '" & Me.txteMail & "', Now(), 1, True"
 

Users who are viewing this thread

Back
Top Bottom