Record update / lockout on button click (1 Viewer)

ashleykitsune

New member
Local time
Today, 12:34
Joined
May 4, 2022
Messages
5
Greetings all, as the title suggests I have a report that I would like to use to lock out records. Reports are not an area I have a lot of experience in yet.
A little background:
The purpose of this database is to check for data errors. The report specifically provides a list of all the errors it found using a short series of queries. Each record provides data from the main table, as well as a "key" field that identifies what record it is from, as well as a hidden lockout checkbox that is tied to a lockout field, as well as a text box where the user provides a synopsis of what they did to remedy the issue.

I want the record to become "disabled" (But still visible - basically make it read only) while the report is open, but update the original table with the lockout check and Notes textbox results. What I mean by this is, i want all the controls for that specific record to become uneditable and gray.
When the report is opened at a later date, the query is set to only show records where the checkbox is false so I don't need to worry about doing that programmatically.

Here's what I'm working with:
Report: Final-Compare_rpt
Main table: HistoricalData_tbl
Checkbox: lockout_chk / Control source: Fixed
Submit button: MarkFixed_btn / Control source: FixNotes
key field: Key_txt / Control source: Key

I honestly don't know where to start, but once I get a good start going, I think I could finish the rest.
Literally all I have:
Code:
Private Sub MarkFixed_btn_Click()


End Sub
Thank you!
~Ashley
 

Ranman256

Well-known member
Local time
Today, 12:34
Joined
Apr 9, 2015
Messages
4,337
before you open the report, run an update query that sets a field say: Locked , to true
then users cant edit if that field = true.

docmd.Setwarnings false
docmd.openquery "quLockTheseRecs"
docmd.openreport "rMyReport
 

ashleykitsune

New member
Local time
Today, 12:34
Joined
May 4, 2022
Messages
5
I'm sorry, I'm not trying to lock the records before opening the report, I'm trying to use the button in the report to lock records.

I worked a little on it a little and decided to use an Update query to try and update a single record's Notes block to "test", but I'm getting a strange issue when doing so. It asks me to provide a value to interpret for some reason.

Code:
Private Sub MarkFixed_btn_Click()
Dim rcdKey As String

rcdKey = Me.KEY
MsgBox rcdKey
DoCmd.RunSQL "UPDATE HistoricalData_tbl SET FixNotes = 'testing' WHERE [key]=" & rcdKey & ";"

End Sub
Using this code the message box returns the value of the key field so I can see it's working right.
I try to run an SQL statement to JUST update that field for that specific record.
But a popup window asks me to "Enter Parameter Value" and it has the value of the first field in the report for that record displayed. I don't understand why this is happening.. do I need to update all the fields? Can I not just update the one field for that record?
~Ashley
 

ashleykitsune

New member
Local time
Today, 12:34
Joined
May 4, 2022
Messages
5
For that last issue, I realized it was a simple text problem. I needed to add single quotes to the variable, so:
WHERE [key]=" & rcdKey & ";"
became
WHERE [key]= '" & rcdKey & "' ;"

But now I need to determine how to set all the controls for that record on the report to "enabled = false"
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:34
Joined
May 7, 2009
Messages
19,237
are you in the Report View?
all controls are Read-only on any view of the report.
 

ashleykitsune

New member
Local time
Today, 12:34
Joined
May 4, 2022
Messages
5
are you in the Report View?
all controls are Read-only on any view of the report.
Is there no way to make a control editable? For instance, I have a text box for the notes. It's not bound to anything, and I want to be able to type a note into the box before clicking "Mark as fixed" but when I do this, the text I add is removed when I click outside that textbox.

I have a workaround that I would prefer not to use, but is there a way?
 

ashleykitsune

New member
Local time
Today, 12:34
Joined
May 4, 2022
Messages
5
i guess you need to use it now or use a Form.
Yea it seems you're right. I added an input box to get the user's notes when they click the button. Ends up doing the same thing but feels more clunky that way. Either way, it works.

Last thing is to make the record not enabled. This is important because I want the user to be able to mark the errors as being fixed, and still see them while using the report.
I think I know how to do it.
~Ashley
 

Users who are viewing this thread

Top Bottom