Results 1 to 14 of 14
  1. #1
    Oblivion_Creed is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2017
    Posts
    20

    allow specific users to make specific actions based on information given in a form

    I have a library project in which there are many library's and each has worker in it.


    When worker enters the project he type in the library in which his working and his ID.
    If all the data is correct than the librarian can take or return books that are assigned to his library.

    now how can i do that?

    my project:

    Login Form:

    I need it to raise an error if ID is not ok (does not exist / dont match with the library)

    Click image for larger version. 

Name:	Untitled.jpg 
Views:	27 
Size:	157.6 KB 
ID:	30838

    here is how the librarians table looks like:

    Click image for larger version. 

Name:	Untitled.jpg 
Views:	28 
Size:	137.6 KB 
ID:	30839






    If user push the button he should be moved to a form where he has options of returning a book , writing a book and so on..


    how can i do such thing?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    you would use vba and an if clause. You haven't provided enough information to provide detailed code but it would perhaps be something like this in the click event for your login button


    Code:
    if dcount("*","tblLibrarians","LibraryNumber=" & me.cboLibrary & " AND IDNumber=" & me.txtLoginID)<>0 then 'there is a match on library and user so user can use this library
        docmd.openform "frmBookOptions"
    else 'user not found for this library
        msgbox "Sorry, you do not have access to this library"
    end if

  3. #3
    Oblivion_Creed is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2017
    Posts
    20
    Quote Originally Posted by Ajax View Post
    you would use vba and an if clause. You haven't provided enough information to provide detailed code but it would perhaps be something like this in the click event for your login button


    Code:
    if dcount("*","tblLibrarians","LibraryNumber=" & me.cboLibrary & " AND IDNumber=" & me.txtLoginID)<>0 then 'there is a match on library and user so user can use this library
        docmd.openform "frmBookOptions"
    else 'user not found for this library
        msgbox "Sorry, you do not have access to this library"
    end if
    what other details should i bring?

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    just realised your idnumber is text, so modify to

    ....AND IDNumber='" & me.txtLoginID & "'")....

    what other details should i bring?
    name of your form you want opening, how you want it opened. names of the controls on your form. what happens if the user is not identified as a valid user (system closed, user given another opportunity to login, etc). whether or not you need to retain the userID for use elsewhere. Whether the form you are opening is a generic form for all libraries or you have different forms for different libraries (which is not generally not recommended)

    Background around how your login form is used - can the user be a member of more than one library? does the user login, take or return a book and logout again, or remains logged in for the day.

    The code I provided is a very basic level. From your description and table, it looks like a user can only be a member of one library - so why ask them to choose a library? As a security measure it doesn't really stand up to scrutiny and will be easily overcome by a user who wants to login as someone else

  5. #5
    Oblivion_Creed is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2017
    Posts
    20
    Quote Originally Posted by Ajax View Post
    just realised your idnumber is text, so modify to

    ....AND IDNumber='" & me.txtLoginID & "'")....



    name of your form you want opening, how you want it opened. names of the controls on your form. what happens if the user is not identified as a valid user (system closed, user given another opportunity to login, etc). whether or not you need to retain the userID for use elsewhere. Whether the form you are opening is a generic form for all libraries or you have different forms for different libraries (which is not generally not recommended)

    Background around how your login form is used - can the user be a member of more than one library? does the user login, take or return a book and logout again, or remains logged in for the day.

    The code I provided is a very basic level. From your description and table, it looks like a user can only be a member of one library - so why ask them to choose a library? As a security measure it doesn't really stand up to scrutiny and will be easily overcome by a user who wants to login as someone else
    My whole project is written in Hebrew, will that be a problem?

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    for me, yes!

    As said, I've provided a basic example - this may be enough for you to move forward or it may not. If it isn't then more detail, along the lines I have suggested, will be required

  7. #7
    Oblivion_Creed is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2017
    Posts
    20
    Quote Originally Posted by Oblivion_Creed View Post
    what other details should i bring?
    Im a real noob and im not sure how to import that...

    Here's the tables name in hebrew with translate, could you please simply copy and paste?

    ספרנים - Librarians table name

    תעודת זהות - ID (of the Librarian in the Librarians table)

    מספר סיפרייה - Library number in the Librarians table


    סיפריות - Library table name

    קוד סיפרייה - Library number in Library table



    if it helps here are the codes in builder to the specific data:

    [ספרנים]![תעודת זהות] - librarian ID in librarian table

    [ספרנים]![מספר סיפרייה] - library number in librarian table

    [סיפריות]![קוד סיפרייה] - library number in library table

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    that is information you have already provided.

    Im a real noob and im not sure how to import that...
    copy and paste in the click event for your login button then correct for name spellings

  9. #9
    Oblivion_Creed is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2017
    Posts
    20
    Quote Originally Posted by Ajax View Post
    that is information you have already provided.

    copy and paste in the click event for your login button then correct for name spellings
    is ther any place there where you can paste that as a code?

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    I don't understand the question - I provided code for you to copy and paste to the click event of your login button

  11. #11
    Oblivion_Creed is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2017
    Posts
    20
    Quote Originally Posted by Oblivion_Creed View Post
    what other details should i bring?
    what me.cbolibrary stands for?

  12. #12
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    the cbo prefix is standard terminology to identify a control as a combobox. You had not provided the names of your controls so I used that instead

  13. #13
    Oblivion_Creed is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2017
    Posts
    20
    Quote Originally Posted by Ajax View Post
    you would use vba and an if clause. You haven't provided enough information to provide detailed code but it would perhaps be something like this in the click event for your login button


    Code:
    if dcount("*","tblLibrarians","LibraryNumber=" & me.cboLibrary & " AND IDNumber=" & me.txtLoginID)<>0 then 'there is a match on library and user so user can use this library
        docmd.openform "frmBookOptions"
    else 'user not found for this library
        msgbox "Sorry, you do not have access to this library"
    end if
    i tried to use the code (changing parameters name) and it gave me this error: "Run Time Error 3464: Data Type Mismatch in criteria expression




    edit: nvm you fixed it

    "

  14. #14
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    my original code assumed that LibraryNumber and IDNUmber were both numeric, but in post #4 I corrected it for txtloginID

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

Similar Threads

  1. Replies: 3
    Last Post: 03-12-2017, 08:29 PM
  2. Replies: 3
    Last Post: 04-25-2016, 04:23 AM
  3. Replies: 1
    Last Post: 10-08-2015, 04:27 AM
  4. Replies: 4
    Last Post: 10-27-2014, 10:26 AM
  5. Replies: 7
    Last Post: 11-29-2009, 01:44 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