Results 1 to 8 of 8
  1. #1
    Troxs is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    7

    Setting Values based on date range for calculated fields

    I'm working on a Database for a buddy, and they need to perform a test to calibrate their equipment. There is a standard calibration number which changes every so often (once, or twice, a month). I need to figure out a way to create an admin side screen for him to input that number so that when his employees calibrate the equipment it'll show a calculated % error as a report when needed. I'm not really sure how to accomplish this. I do not want them to always have to enter the standard number when inputing the data, but I want to make sure that if he were to run a report 6 months from now he would be able to see the %error from that time frame based on the standard calibration number at that time...



    I'll try to explain this in another way incase that is confusing...

    Table
    Date || Shift || Reading || Standard# || %Error

    I need to have the standard number automatically entered into this table based on a number set by the admin, but not have to be typed in daily or every time a record is entered. The number must be set via a form.

    I hope this makes sense.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    The employee form would have the admin field locked.
    the admin form allows for change.
    Make a table of admins, tAdmins, with all admin user IDs.

    you can enable this lock by looking at the userId when the form opens....
    Code:
    sub form_load()
    dim vUser
    dim bIsAdmin as bBoolean
    VUser = Environ("username")
    BIsAdmin =not IsNull(dlookup("[userId]","tAdmins","[userId]='" & vUser & "'"))
    
    TxtRate.locked =not IsAdmin
    end sub

  3. #3
    Troxs is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    7
    Sorry, I have the admin screen set up. What I'm trying to figure out is how to get the number from a text box on the admin form (even if not open) and place it into the table [the table that the employees would be editing] automatically when a new record is made.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    Use DLOOKUP to pull that value into the field on new record event.

    txtBox = Dlookup(field,table)

  5. #5
    Troxs is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    7
    If I used the DLOOKUP would it change the value on that record when the source changes? I'm looking to place the latest value from another table into each new record and it stay that value for that date.

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    No ,the field on the form is an unbound text box. It can't affect the source table.

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Date || Shift || Reading || Standard# || %Error
    "Date" is a reserved word in Access and shouldn't be used for object names. Plus, it is not very descriptive... "Date" of what?
    Object names should only be letters and numbers..... NO spaces, special characters or punctuation.


    I need to have the standard number automatically entered into this table based on a number set by the admin, but not have to be typed in daily or every time a record is entered. The number must be set via a form.
    Have a form to edit the standard number.

    In the main readings form, use the before update event to add the standard number before the save.



    This dB is to demonstrate how to update a value in a form from a table using the FROM before update event.
    Attached Files Attached Files

  8. #8
    Troxs is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    7
    Thank you! This worked, for my needs! Sorry, my email client decided to move the notification to spam and I'm just now seeing the reply.

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

Similar Threads

  1. Replies: 22
    Last Post: 01-23-2015, 01:16 PM
  2. Replies: 9
    Last Post: 10-07-2014, 06:53 PM
  3. Replies: 1
    Last Post: 03-27-2014, 06:42 AM
  4. Query Date Range Based on Calculated Fields
    By wilsoa in forum Queries
    Replies: 6
    Last Post: 03-08-2012, 02:41 PM
  5. Setting criteria in a calculated date field
    By SteveReberger in forum Access
    Replies: 0
    Last Post: 10-29-2008, 06:58 AM

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