Results 1 to 4 of 4
  1. #1
    pbs is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    6

    Lightbulb blok record

    Hello,

    I'am a new beginner with Access 2019 and i try to make a database,
    I have a field 'blok' (J/N) in my database artikle


    question: i have made a form (Fartikele), when i click on field 'blok' i want to block that record, so it can not be edited except the field 'blok', until click 'blok' again in the same record.
    How can i do that.
    Sorry for my bad english

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,799
    What usually works out well is, you write in your native language into Google translate, then paste the English here. You can paste both language versions if you think that will help.
    In the meantime, you're saying you want to click on a field in a record and switch that field from being editable to not editable, but if you click that field again you want it to revert back to being editable?
    I'm going to guess at the language.
    Ono što obično uspije, jeste da napišete na svom maternjem jeziku u Google translate, a zatim ovdje zalijepite engleski. Možete zalijepiti obje jezične verzije ako mislite da će vam to pomoći.
    U međuvremenu kažete da želite kliknuti polje u zapisu i prebaciti to polje iz uređivanog u neuređivo, ali ako ponovo kliknete to polje, želite da se vrati natrag u uređivano?
    Pogodit ću jezik.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,925
    I am going to take a punt at it despite the language problem.

    Amend the name of the control to suit

    Code:
    Private Sub Text25_Click()
    Me.AllowEdits = Not Me.AllowEdits
    End Sub
    I would however put some sort of display on the form to show which mode it is in, as otherwise it would get very confusing to the user?

    HTH
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Here's my punt. I blocked / unblocked with a command button instead of a text box.

    1. write a sub to toggle the form, the field, and the controls as blocked or unblocked. Sorry (I used Locked instead of Blocked in my example)
    Code:
    Private Sub ToggleLock(IsLocked As Boolean)
        Me.AllowEdits = Not IsLocked 'dont allow edits if it's locked
        Me.IsLocked = IsLocked 'the field in the table that controls if the row is locked
        
        'Change the caption of the command button
        If IsLocked Then Me.cmdLock.Caption = "Unlock" Else Me.cmdLock.Caption = "Lock"
        
        'enable/disable all of the controls on the form so the user understands. when a control is not enabled access will grey it out
        Me.CONTROL_NAME_1.Enabled = Not IsLocked
        Me.CONTROL_NAME_2.Enabled = Not IsLocked
        Me.CONTROL_NAME_3.Enabled = Not IsLocked
        ...
        Me.CONTROL_NAME_N.Enabled = Not IsLocked
        
    End Sub
    2. Call this sub from the form's Current event to setup the form each time the record changes:
    Code:
    Private Sub Form_Current()
        'If Me.IsLocked Then
        '    ToggleLock True
        'Else
        '    ToggleLock False
        'End If
    
        ToggleLock Me.IsLocked
        
    End Sub


    3. Call this sub from the block/unblock command button
    Code:
    Private Sub cmdLock_Click()
        'If Me.IsLocked Then
        '    ToggleLock False
        'Else
        '    ToggleLock True
        'End If
        
        ToggleLock Not Me.IsLocked
    
    End Sub

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

Similar Threads

  1. Replies: 1
    Last Post: 08-12-2020, 12:27 AM
  2. Replies: 2
    Last Post: 02-28-2019, 03:49 PM
  3. Replies: 5
    Last Post: 08-18-2018, 10:23 AM
  4. Replies: 4
    Last Post: 10-21-2017, 09:56 AM
  5. Replies: 4
    Last Post: 01-12-2016, 02:49 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