UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Prevent Edit Record If Checkbox Value = True, Access 2013    
 
   
Alhakeem1977
post Sep 18 2017, 03:11 PM
Post#1



Posts: 64
Joined: 8-July 17



How to fix this code to prevent editing a record which has an action taken by another user?
What I want to if the checkbox called (Receved) clicked "=True" by another user then not allow editing the record.

Form info:
*DocID is a numeric field.
*Control Source: tblFacilityRegister
*Received is Checkbox


CODE
Me.Received.Value = DCount("DocID", "tblfacilityregister", "received=" & True)

  Me.AllowEdits = False
  
Beep
MsgBox "You are not allowed to change this record, the physical document has already been acknowledged, please contact Document Control.", vbExclamation, "Acknowledged Document"


Thanks in advance.

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 
Jeff B.
post Sep 18 2017, 05:19 PM
Post#2


UtterAccess VIP
Posts: 9,885
Joined: 30-April 10
From: Pacific NorthWet


What happens if user #2 UN-CHECKS the checkbox? What if user #1 decides he/she made a mistake and needs to uncheck the checkbox?

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
Alhakeem1977
post Sep 18 2017, 10:48 PM
Post#3



Posts: 64
Joined: 8-July 17



Thanks for your kind response, obviously the database is works as a Log book sending physical documents between two Departments user #1 is a sender and user #2 is a receiver both are using different forms for their entries.
If user #1 made a record to send a document he / she will be allowed to change the record unless the user #2 has received the document by click the checkbox (Received) in another form.
The code will be placed in the sender form to prevent change the record.

Thanks in advance

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 
Jeff B.
post Sep 19 2017, 07:23 AM
Post#4


UtterAccess VIP
Posts: 9,885
Joined: 30-April 10
From: Pacific NorthWet


Have you looked into adding an If...Then... expresssion?

If the checkbox is true (i.e., checked), AllowEdits = False.

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
Alhakeem1977
post Sep 19 2017, 09:57 AM
Post#5



Posts: 64
Joined: 8-July 17



Yes I tried but I couldn't.
Can you help to provide me with the code by using Dlookup or Dcount function ?

Your earliest response is highly appreciated

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 
Jeff B.
post Sep 19 2017, 11:48 AM
Post#6


UtterAccess VIP
Posts: 9,885
Joined: 30-April 10
From: Pacific NorthWet


It would help folks here at UA to see what you tried, and to learn what happened ("it didn't work" doesn't give us much to go on...)

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
Alhakeem1977
post Sep 19 2017, 02:33 PM
Post#7



Posts: 64
Joined: 8-July 17



I tried the below code it gives me Run-time error '4364' mismatch in criteria expression.


CODE
Private Sub Form_Current()

Me.AllowEdits = Nz(DLookup("DocID", "tblfacilityregister", "[received] = '" & Me!txtSenderID & "' And [Received] = False"), 0)

Beep
MsgBox "This document has been already acknowledged, please contact Document Control.", vbExclamation, "Notice"
End Sub

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 
Jeff B.
post Sep 20 2017, 08:26 AM
Post#8


UtterAccess VIP
Posts: 9,885
Joined: 30-April 10
From: Pacific NorthWet


The error message you posted suggests that the data type(s) of your criteria don't match the data type(s) of the field(s). Re-check the data types of all the variables.

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
Alhakeem1977
post Sep 20 2017, 02:29 PM
Post#9



Posts: 64
Joined: 8-July 17



Thanks dear,
I tried to change the code in many ways always I am getting many errors can you amend the code if you could?

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 
Alhakeem1977
post Sep 20 2017, 04:01 PM
Post#10



Posts: 64
Joined: 8-July 17



Below my form ' frmFacilityEdit' data source:

Table source : tblFacilityRegister
1. DocID 'Long integer'
2. Received 'Checkbox'
3. txtUserID 'Text'

My target again is to allow editing the entier entry if the checkbox (Received) is not clicked Else
If the Checkbox 'Received' been clicked earlier then allow edit to the same record is disabled (Allow edits = Flase)

Thanks a lot

--------------------
Best Regards,

Al Hakeem1977
Go to the top of the page
 
Jeff B.
post Sep 21 2017, 07:57 AM
Post#11


UtterAccess VIP
Posts: 9,885
Joined: 30-April 10
From: Pacific NorthWet


Perhaps another of the many folks here at UA can volunteer to provide coding suggestions. I prefer to suggest direction(s) and have you do the work -- it must be the former teacher in me.

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    18th December 2017 - 05:37 AM