Results 1 to 6 of 6
  1. #1
    framar is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    3

    Help with access 2010 coding

    Hi all i have this database and with it onloading it checks the user name and gets the user level from a table "userstable", and if the user was not in the table it would auto add the user to the table,when it was a standalone it worked fine now i have moved it to a split database on a sql server it wont work!!!!.
    here is the coding i was useing if anyone can help it would be great, and it is in Access 2010





    Code:
    If IsNull(Me.[winid]) Then
            DoCmd.SetProperty "newpermitholder", acPropertyVisible, "0"
            DoCmd.SetProperty "Todayspermits", acPropertyVisible, "0"
            DoCmd.SetProperty "Daily Report Open Permits", acPropertyVisible, "0"
            DoCmd.SetProperty "Permitholderslist", acPropertyVisible, "0"
            DoCmd.SetProperty "newcompany", acPropertyVisible, "0"
            DoCmd.SetProperty "print_dashboard", acPropertyVisible, "0"
            DoCmd.SetProperty "Command71", acPropertyVisible, "0"
            DoCmd.SetProperty "Command74", acPropertyVisible, "0"
            DoCmd.SetProperty "Command75", acPropertyVisible, "0"
            End If
            If IsNull(Me.[winid]) Then
            Dim Rs As DAO.Recordset
            Set Rs = CurrentDb.OpenRecordset(userstable)
            Rs.AddNew
            Rs("LoginID") = GetUser()
            Rs.Update
            Rs.Close
            Set Rs = Nothing
            MsgBox "First Time Log in Please Restart Database", vbApplicationModal, "GUEST LOGIN"
            DoCmd.Quit acPrompt
    End If

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why doesn't it work - error message, wrong results, nothing happens?

    You are setting visible property of controls on form?

    I would use:
    Me.newpermitholder.Visible = Not IsNull(Me.[winid])

    And to add record to table:
    If IsNull(Me.[winid]) Then
    CurrentDb.Execute "INSERT INTO usertable(LoginID) VALUES('" & GetUser() & "'"
    MsgBox "First Time Log in Please Restart Database", vbApplicationModal, "GUEST LOGIN"
    DoCmd.Quit acPrompt
    End If

    Why does the db need to be restarted?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    framar is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    3
    ok it would not do anything and then if i changed the file to a accdr it would do a runtime error
    i have levels of access so that was the only way i knew how
    and as far as being restarted it would not update the the access level for the user untill it had been restarted
    but on the up side i got it working about 10 min ago lol
    thanks for the reply
    here is the code i used
    If (IsNull(winid)) Then
    DoCmd.SetProperty "newpermitholder", acPropertyVisible, "0"
    DoCmd.SetProperty "Todayspermits", acPropertyVisible, "0"
    DoCmd.SetProperty "Daily Report Open Permits", acPropertyVisible, "0"
    DoCmd.SetProperty "Permitholderslist", acPropertyVisible, "0"
    DoCmd.SetProperty "newcompany", acPropertyVisible, "0"
    DoCmd.SetProperty "print_dashboard", acPropertyVisible, "0"
    DoCmd.SetProperty "Command71", acPropertyVisible, "0"
    DoCmd.SetProperty "Command74", acPropertyVisible, "0"
    DoCmd.SetProperty "Command75", acPropertyVisible, "0"
    DoCmd.SetWarnings False
    sSQL = "INSERT INTO [userstable] ([loginid]) VALUES ('" & GetUser() & "')"
    DoCmd.RunSQL (sSQL)
    DoCmd.SetWarnings True
    MsgBox "First Time Log in Please Restart Database", vbApplicationModal, "GUEST LOGIN"
    DoCmd.Quit acPrompt
    End If

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Glad it is working now.

    The CurrentDb.Execute method does not need the SetWarnings code.

    What do you mean by 'update the the access level for the user'? Where is that level stored that you can't change it?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    framar is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    3
    ok so the flow is new user runs database database says o its a new user i will add the username to the userstable (in that table there is loginid and security level) security level is automaticly at GUEST then the database closes, so next time they log in they are in the userstable and sets the form view options on all the pages in the database
    what i found is if i did not do the closedb it would allow someone to access pages they should not see

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I would have to see the code that 'sets the form view options on all the pages in the database'. Why couldn't this code be called and run for the new user?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 0
    Last Post: 07-31-2012, 12:25 PM
  2. Replies: 1
    Last Post: 05-15-2012, 06:04 PM
  3. Need Help with Access vb coding
    By Entrimo in forum Access
    Replies: 1
    Last Post: 02-19-2012, 06:15 PM
  4. Access without coding
    By kp123 in forum Access
    Replies: 4
    Last Post: 11-25-2011, 03:50 PM
  5. parsing data in access (coding?)
    By banker247 in forum Programming
    Replies: 0
    Last Post: 01-13-2009, 12:05 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