Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Join Date
    Aug 2009
    Posts
    61

    Unanswered: Lock Data Feilds After Change

    Hi There,

    I am trying to lock a data field in a form after the user has updated the information. The users are double clicking to enter the date and time that they carried out a process, but I do not want them to be able to change previous time stamps. The database is being used to track production on a manufacturing floor.

    How do I stop them from changing this? They need to be able to see the entire form all the time and will be updating records on the same row (in different feilds).

    Should the code be written in After Update in the properties of the feild?

    Look forward to a reply.

  2. #2
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Quote Originally Posted by mbsmith
    Hi There,

    I am trying to lock a data field in a form after the user has updated the information. The users are double clicking to enter the date and time that they carried out a process, but I do not want them to be able to change previous time stamps. The database is being used to track production on a manufacturing floor.

    How do I stop them from changing this? They need to be able to see the entire form all the time and will be updating records on the same row (in different feilds).

    Should the code be written in After Update in the properties of the feild?

    Look forward to a reply.
    Hi mbsmith,
    One simple way is to set your Form to AllowEdits = No
    Then create a CommandButton and within it set it to: Me.AllowEdits = True
    Then in the Forms AfterUpdate event set it back to Me.AllowEdits = False.
    You can also do that just for specific fields only. Give it a try and see what you think. Although someone else may have a more elaborate way of doing it, that's just what I have done and has worked for a few years.

    have a nice one,
    BUD

  3. #3
    Join Date
    Aug 2009
    Posts
    61
    Hi Bud,

    Thanks for your help, unfortunately I cannot get that to work. I am very new at access and do not follow exactly where you want me to put all the information.

    Where exactly do I put that command within the command button?

    Also, do I just paste these commands into the line of the properties, or do I have to paste it in the visual basics screen?

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Where exactly do I put that command within the command button?
    Typically it's OnClick event.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Aug 2009
    Posts
    61
    It still does not work. I have some code in certain fields of the form. Would that make a difference?

    In the dbclick event I have a code to allow users to double click and add the date and time. The code is as follows:

    Private Sub PICK_DATE_DblClick(Cancel As Integer)
    Me.PICK_DATE.Value = Now()
    End Sub

    Should I add to this code so that edits will not be allowed after the data is entered?

    Thanks for all the help I am receiving so far!

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Code:
    Private Sub PICK_DATE_DblClick(Cancel As Integer)
       Me.PICK_DATE.Value = Now()
       Docmd****nCommand accmdSaveRecord
       Me.AllowEdits = False
    End Sub
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Dammit I really wish the forum noobs would fix this stupid post-destroyer.
    Replace the stars with DOT-R-U.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I believe the fine folks at vBulletin are the noobs you seek. The "*" replacement was not arbitrary selected by administration.

    vBulletin Manual - Censorship Options

    I suppose you could argue for use of replacement variables, but that's not what they're designed for as I understand them.

    Note that we have had this discussion among the moderators.
    Last edited by Teddy; 08-27-09 at 23:37.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by StarTrekker
    Dammit I really wish the forum noobs would fix this stupid post-destroyer.
    Replace the stars with DOT-R-U.
    the alternative approach is to encourage the ISP's in Rumania to drop their spammers.. a decision was taken here a while ago to mask all .dot**** and sadly that casues problems for docmd.dot****nsql

    I beleive there is soemthign ongoing to try and resolve the issue with a different version of vBulletin, but I wouldn't expect it to happen anytime soon
    I'd rather be riding on the Tiger 800 or the Norton

  10. #10
    Join Date
    Aug 2009
    Posts
    61
    Quote Originally Posted by StarTrekker
    Dammit I really wish the forum noobs would fix this stupid post-destroyer.
    Replace the stars with DOT-R-U.

    Okay I tried that code and now I am getting the following error:

    Compile error:
    Expected: end of stement.

    My code looks like this:

    Private Sub PICK_DATE_DblClick(Cancel As Integer)
    Me.PICK_DATE.Value = Now()
    DoCmd DOT - R-UnCommand accmdSaveRecord
    Me.AllowEdits = False
    End Sub

    I am using access 2003..not sure if that makes a difference on the code. Am I supposed to put the code anywhere else than on dblclick of the feild properties?

  11. #11
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Quote Originally Posted by mbsmith
    Okay I tried that code and now I am getting the following error:

    Compile error:
    Expected: end of stement.

    My code looks like this:

    Private Sub PICK_DATE_DblClick(Cancel As Integer)
    Me.PICK_DATE.Value = Now()
    DoCmd DOT - R-UnCommand accmdSaveRecord
    Me.AllowEdits = False
    End Sub

    I am using access 2003..not sure if that makes a difference on the code. Am I supposed to put the code anywhere else than on dblclick of the feild properties?
    Sorry I've been out of pocket for a few. Could you just POST your DB to the forum so that I can maybe take a look at it? Do remove any pertinent info. before you do though. Save it as a .zip file and upload here. But typically speaking, you would put that in the OnClick event as stated behind a CommandButton that you would create. You did create a CommandButton to activate your choice...correct?

  12. #12
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    K, so I can't help easily because I can't type what is needed with the way the forum is set up.

    That line needs to be:

    Docmd.XRunCommand accmdSaveRecord

    But without the X.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  13. #13
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Or just put in a refresh command:

    Refresh
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  14. #14
    Join Date
    Aug 2009
    Posts
    61
    Quote Originally Posted by Bud
    Sorry I've been out of pocket for a few. Could you just POST your DB to the forum so that I can maybe take a look at it? Do remove any pertinent info. before you do though. Save it as a .zip file and upload here. But typically speaking, you would put that in the OnClick event as stated behind a CommandButton that you would create. You did create a CommandButton to activate your choice...correct?

    I have attached a copy of the db. I have changed the code only in pick date on the form. Any help that you can give would be very appreciated.
    Attached Files Attached Files

  15. #15
    Join Date
    Aug 2009
    Posts
    61
    Quote Originally Posted by StarTrekker
    K, so I can't help easily because I can't type what is needed with the way the forum is set up.

    That line needs to be:

    Docmd.XRunCommand accmdSaveRecord

    But without the X.

    I put that in and now it is giving me run time error 2046: The command or action 'SaveRecord' isn't available now.

    What do I do about this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •