Results 1 to 14 of 14
  1. #1
    Haggrr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    18

    Making records un-editable

    Sample of table I would like to lock.

    Job Number SetterCompany Date To Date From Amount File Number Text Code
    849505 ABC Manufacturer
    12/30/14 1:11:59 PM
    2588811

    849505 Mike Byod 12/30/14 1:35:07 PM

    2588842 Wednesday

    Where, only records that fit this parameter is editable.

    Function LastThurs() As Date
    'This will find last Thursday's date
    Dim strDates As Date
    Dim intDay As Integer
    intDay = Weekday(Date) 'Finds today's day of the week
    Select Case intDay
    Case 1 'Sunday!
    strDates = Date - 3
    Case 2 'Monday
    strDates = Date - 4
    Case 3 'Tuesday
    strDates = Date - 5
    Case 4 'Wednesday
    strDates = Date - 6
    Case 5 'Thursday
    strDates = Date
    Case 6 'Friday
    strDates = Date - 1
    Case 7 'Saturday


    strDates = Date - 2
    End Select
    LastThurs = strDates
    End Function

    And I know simply changing the computer's date will negate, but that doesn't concern me as of now! Thanks Haggrr

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    User's should not be working directly with tables and queries. Bind form to filtered query.
    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
    Haggrr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    18
    I hear you and completely agree! However, the database I use has been work in progress for more than ten years (my main table is labeled [table1]), and I can't go to every form to accomplish that. How I achieve this now is limiting the 'Validation Rule' for both [table][date to] and [table][date from]. Might I use my 'Last Thurs ()' module to accomplish my need?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Tables and queries can't have code behind them. If users can get to the Navigation pane and ribbon, they can do whatever they want.

    I've never set those properties on fields in table. And setting Validation Rule will not limit the records viewed or editable. It controls what users are allowed to enter into the field.
    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
    Haggrr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    18
    Okay. Would it be possible for you to give me an example of a bound form based on the info I provided?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Build query object with static filter criteria. Set form RecordSource to that query object. Or put an SQL statement directly in the RecordSource.

    The calculation to determine date of a particular day of week can be done without VBA. What do you consider the beginning of week - Sunday?

    ThurThisWeek: Date - Weekday(Date, vbSunday) + 5
    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.

  7. #7
    Haggrr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    18
    Beginning of the work week is Thursday and ending on Wednesday.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Did you try the expression? Adjust as needed.
    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.

  9. #9
    Haggrr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    18
    You have me on the right track here. Let me show you more of what I'm looking for.

    Once any user enters data the only way to access those records is through a query labeled 'search'. Where [job number] is the parameter being sought. See below.


    SELECT Table1.[Job Number], Table1.SetterCompany, Table1.[Date To], Table1.[Date From], Table1.Amount, Table1.[File Number], Table1.Text, Table1.Code
    FROM Table1
    WHERE (((Table1.[Job Number])=[Enter Job #]))
    ORDER BY Table1.[File Number];

    I'm trying to exclude any record, where [date to] or [date from] is outside the current work week of Thursday through Wednesday from being changed - is any way?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    That gets complicated. Try:

    SELECT * FROM Table1 WHERE
    Not ([Date To] BETWEEN Date - Weekday(Date, vbThursday) + 1 AND Date - Weekday(Date, vbThursday) + 7
    Or
    [Date From] BETWEEN Date - Weekday(Date, vbThursday) + 1 AND Date - Weekday(Date, vbThursday) + 7);
    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.

  11. #11
    Haggrr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    18
    I'm sincerely sorry, but can you complete my SQL to include your addition? And remember, I don't mind these records being accessed, just not changed. Thanks for your patience with me!

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    The only way to prevent editing records is to not present them to user by filtering them out of the dataset.

    WHERE (((Table1.[Job Number])=[Enter Job #])) AND {insert my suggested criteria here without curly braces}

    Also, I NEVER use dynamic parameter input popups. Cannot validate user input. User input of filter criteria should be done on a form and query refers to input control on form. Actually, I don't even do that - I use VBA to set form Filter property.
    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.

  13. #13
    Haggrr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    18
    Well, thanks for telling me what I shouldn't do and assuming I'm as well versed as you. There used to be a site where people like Spencer and someone named Gary would really try to help us novices out. Do you know where that might be?

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Try the query anyway and see if it works with your popup input.

    If you are interested in the alternatives we can explore those options.
    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: 2
    Last Post: 04-16-2014, 03:43 PM
  2. Replies: 12
    Last Post: 11-21-2012, 01:51 PM
  3. Making a field non-editable after save
    By carlyd in forum Forms
    Replies: 10
    Last Post: 02-18-2012, 08:23 AM
  4. Making subforms editable
    By ashiers in forum Forms
    Replies: 7
    Last Post: 10-08-2008, 04:09 PM
  5. making specific fields non-editable
    By narayanis in forum Forms
    Replies: 3
    Last Post: 08-06-2008, 12:22 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