hello, vbajock!
the short answer to your question is yes, the two fields do definitely exist in the underlying table/recordsource.
the unexpurgated answer is as under:
following's the code for the 'Print' button
============================================================
Private Sub Command39_Click()
On Error GoTo Err_Command39_Click
Dim stDocName As String
Dim Last_printedBL As Date
Me.Refresh
MsgBox "setting locked to true and evaluating ""now"""
Me!Form_LockedBL = True
Me!Last_printedBL = Now()
MsgBox "dim rs as dao.recordset statement"
Dim rs As dao.Recordset
MsgBox "set rs = ms.recordsetclone statement"
Set rs = Me.RecordsetClone
If Not rs.EOF Then
rs.MoveFirst
Do While Not rs.EOF
rs.Edit
MsgBox "setting form_locked value to me!..."
rs("Form_LockedBL").Value = Me!Form_LockedBL.Value
MsgBox "setting form_printed value to now"
rs("Last_PrintedBL").Value = Me!Last_printedBL.Value
rs.Update
rs.MoveNext
Loop
End If
Set rs = Nothing
stDocName = "RECIST Disease Evaluation: Baseline"
OpenReport_FX stDocName, acNormal, "", "[Patient Number] = " & Me.[Patient Number]
Me.EnableEditsBtn.Visible = True
' MsgBox "Edits button should have appeared"
Me.EnableEditsBtn.SetFocus
Me.Command39.Visible = False
' MsgBox "Print button should have disappeared"
Me.AllowEdits = False
' MsgBox "Disallowed Edits on current form"
' now take care of the fact that disallowing edits on current form does not disable
' the calendar buttons in the detail section
Dim ctl As Control
For Each ctl In Me.Detail.Controls
Select Case ctl.ControlType
Case acCommandButton
ctl.Enabled = False
End Select
Next ctl
' MsgBox "Disallowed edits for dates"
Exit_Command39_Click:
Exit Sub
Err_Command39_Click:
MsgBox Err.description
Resume Exit_Command39_Click
End Sub
============================================================
there are two more vba codings that probably require ministering to.
the next is for a button 'EnableEditsBtn' which on getting clicked enables the form/controls for editing
============================================================
Private Sub EnableEditsBtn_Click()
Dim ctl As Control
For Each ctl In Me.Detail.Controls
Select Case ctl.ControlType
Case acCommandButton
ctl.Enabled = True
End Select
Next ctl
Me!Form_LockedBL = False
MsgBox "dim rs as dao.recordset statement"
Dim rs As dao.Recordset
MsgBox "set rs = ms.recordsetclone statement"
Set rs = Me.RecordsetClone
If Not rs.EOF Then
rs.MoveFirst
Do While Not rs.EOF
rs.Edit
MsgBox "setting form_locked value to me!..."
rs("Form_LockedBL").Value = Me!Form_LockedBL.Value
rs.Update
rs.MoveNext
Loop
End If
Set rs = Nothing
' MsgBox "Form_Locked set to False"
Me.AllowEdits = True
' MsgBox "Edits are allowed again"
Me.Command39.Visible = True
' MsgBox "Print button is now visible"
Me.Command39.Enabled = True
' MsgBox "Print button is now enabled"
Me.Command39.SetFocus
' MsgBox "Print button how has focus"
Me.EnableEditsBtn.Visible = False
' MsgBox "edit button has disappeared"
End Sub
============================================================
lastly, i need to be concerned with what happens to the buttons as the user scrolls from one record to the next, so for the event property 'OnCurrent', i have this one
============================================================
Private Sub Form_Current()
If mintLASSecurityLevel <> 11 And Me!Form_LockedBL = True Then
MsgBox "sec level is " & mintLASSecurityLevel & " user is " & LAS_GetUserName & " flag is " & Me!Form_LockedBL
For Each ctl In Me.Detail.Controls
Select Case ctl.ControlType
Case acCommandButton
ctl.Enabled = False
End Select
Next ctl
Me.AllowEdits = False
Me.EnableEditsBtn.Visible = True
Me.Command39.Visible = False
Me.Form_Locked_Label.Visible = False
ElseIf mintLASSecurityLevel <> 11 And Me!Form_LockedBL = False Then
MsgBox "sec level is " & mintLASSecurityLevel & " user is " & LAS_GetUserName & " flag is " & Me!Form_LockedBL
For Each ctl In Me.Detail.Controls
Select Case ctl.ControlType
Case acCommandButton
ctl.Enabled = True
End Select
Next ctl
Me.AllowEdits = True
Me.EnableEditsBtn.Visible = False
Me.Command39.Visible = True
Me.Form_Locked_Label.Visible = False
ElseIf mintLASSecurityLevel = 11 Then
MsgBox "sec level is " & mintLASSecurityLevel & " user is " & LAS_GetUserName & " flag is " & Me!Form_LockedBL
For Each ctl In Me.Detail.Controls
Select Case ctl.ControlType
Case acCommandButton
ctl.Enabled = False
End Select
Next ctl
Me.EnableEditsBtn.Visible = False
Me.Command39.Visible = False
If Me!Form_LockedBL = True Then
Me.Form_Locked_Label.Caption = "Locked to edits"
Me.Form_Locked_Label.ForeColor = 255
Else
Me.Form_Locked_Label.Caption = "Edits Enabled"
Me.Form_Locked_Label.ForeColor = 0
End If
End If
End Sub
============================================================
to test this all out, i have a Patient_ID with three values of Test_Number in the record source table underlying the form and attempt to simulate a user's deciding to print a report(which should simultaneously lock all records of this continuous form's from editing and display a button 'Enable Edits' while also causing 'Print' button to disappear). then i attempt to 'Enable Edits' again (which should do just that for all three records that can be viewed w/ this form and hide the 'Enable Edits' button and cause the 'Print' button to reapper).
i position the pointer onto the 2nd of the three records and hit the Print button (command_39) and the code runs seemingly successfully: the three records for this Patient number have the same datetime and the check-box 'on' in the relevant fields under discussion. continuing w/ the test, i position the pointer onto the third and final record, hit the 'Enable Edits' button and the code didn't seemed to work OK - the Form_LockedBL column in the recordsource is now blank ('no') just for the third record of this Patient_ID's
can you find the achilees heel in all this?
“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln