Results 1 to 7 of 7
  1. #1
    Robert2150 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Location
    Sparks, Nv
    Posts
    102

    Limiting records that may be viewed in a form based upon password or user name.

    I have a database that contains data for many buildings. I wish to limit the buildings that can be viewed on my main form based upon a User's Username.



    I have a table called tblUsers wihich contains the UserName, Password, and a field called PropertySort which contains a short name for the group that I want to sort by.

    I have a log in form called frmLogin where a user selects their UserName and enters their Password. When the SUBMIT BUTTON on this Login Form is Clicked, a TmpVar is created with the User Name, I have also created a TmpVar that contains the PropertySort Entry, to be used in the Query.

    The Query populates a combo box drop down which displays the building to be selected and loaded in my main form.

    My problem is that if the Query is empty, the code works, and only the buildings for a particular user is available, however, if I go out of the program and log back in as a different user, buildings for both users show in the Dropdown Box.

    How do I clear the information from the previous query to only show the buildings for the current User?

    Thanks in advance for any help.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    How about posting the SQL for the RowSource of your ComboBox?

  3. #3
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    if I go out of the program and log back in as a different user
    If you are actually closing down the db and logging in as someone else when you get this problem, there's no way you need to "clear the query". There must be something wrong with what/how you're assigning values based on the current user. I think more info around that part of the process needs to be supplied, or you need to check what values are being passed by using temporary message boxes or Debug.Print statements if you can step through what happens after the log in.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Robert2150 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Location
    Sparks, Nv
    Posts
    102

    Smile Will check out some items.

    Quote Originally Posted by Micron View Post
    If you are actually closing down the db and logging in as someone else when you get this problem, there's no way you need to "clear the query". There must be something wrong with what/how you're assigning values based on the current user. I think more info around that part of the process needs to be supplied, or you need to check what values are being passed by using temporary message boxes or Debug.Print statements if you can step through what happens after the log in.
    Thanks, let me check some things out, and I will get back to you with more information.

    Thank you for your help.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Would you care to post your dB for analysis? A lot of the time it is easier and faster to see the dB.


    It sounds like you are going through a lot of extra effort using tmpVars. The combo box has the name and the PropertySort Entry.
    Just have the main form query reference the combo box values.


    You can't actually "clear out" a query. A query does not store data. A query gets data from a table (mostly - can create "virtual fields" that are not in tables). But once the query switches to design view, SQL view or is closed, the data is "gone" (from the query).

  6. #6
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by ssanfu View Post
    You can't actually "clear out" a query.
    Absolutely correct. I took the comment differently - that the combo box was what needed "clearing out" but didn't suggest a requery on it because there seems to be an issue with the current user value when logging in as someone else.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Robert2150 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Location
    Sparks, Nv
    Posts
    102
    OK, will get back to you.

    Thank you.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-25-2016, 10:57 AM
  2. Limiting access to a record with a password.
    By Robert2150 in forum Access
    Replies: 1
    Last Post: 04-11-2016, 05:08 AM
  3. Replies: 19
    Last Post: 04-23-2013, 05:45 PM
  4. Form limiting records
    By yaro.kobzar in forum Programming
    Replies: 1
    Last Post: 05-21-2011, 06:50 AM
  5. Replies: 4
    Last Post: 07-28-2010, 10:27 AM

Tags for this Thread

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