D
DJJ
I created the following procedure to selectively lock and unlock specific
records in a form. It works well using a combination of SQLServer Tables
(Using ODBC) and Access tables but when I converted to all SQLServer Tables
I got the following error. The only thing I can think of is that field that
is the control source for the check box that's locks the records is now
stored with -1 and 0 (SQLServer) but I don't know how to get around that.
Would greatly appreciate any input.
The Event (compile error - invalid use of property):
Private Sub Form_Current()
Call Locked(Me, Me.frmCollNameDataEntrySub, Me.chkLocked)
End Sub
The Standard Module Code:
Public Sub Locked(frm As Form, sfrm As SubForm, chk As CheckBox)
On Error Resume Next
Dim ctl As Control
If chk.Value = True Then
For Each ctl In frm.Controls
With ctl
Select Case .ControlType
Case acTextBox
.Locked = True
Case acComboBox
.Locked = True
Case acSubform
.Locked = True
End Select
End With
Next ctl
frm.AllowDeletions = False
sfrm.Form.AllowDeletions = False
ElseIf chk.Value = False Then
For Each ctl In frm.Controls
With ctl
Select Case .ControlType
Case acTextBox
.Locked = False
Case acComboBox
.Locked = False
Case acSubform
.Locked = False
End Select
End With
Next ctl
frm.AllowDeletions = True
sfrm.Form.AllowDeletions = True
End If
Set ctl = Nothing
Set frm = Nothing
End Sub
records in a form. It works well using a combination of SQLServer Tables
(Using ODBC) and Access tables but when I converted to all SQLServer Tables
I got the following error. The only thing I can think of is that field that
is the control source for the check box that's locks the records is now
stored with -1 and 0 (SQLServer) but I don't know how to get around that.
Would greatly appreciate any input.
The Event (compile error - invalid use of property):
Private Sub Form_Current()
Call Locked(Me, Me.frmCollNameDataEntrySub, Me.chkLocked)
End Sub
The Standard Module Code:
Public Sub Locked(frm As Form, sfrm As SubForm, chk As CheckBox)
On Error Resume Next
Dim ctl As Control
If chk.Value = True Then
For Each ctl In frm.Controls
With ctl
Select Case .ControlType
Case acTextBox
.Locked = True
Case acComboBox
.Locked = True
Case acSubform
.Locked = True
End Select
End With
Next ctl
frm.AllowDeletions = False
sfrm.Form.AllowDeletions = False
ElseIf chk.Value = False Then
For Each ctl In frm.Controls
With ctl
Select Case .ControlType
Case acTextBox
.Locked = False
Case acComboBox
.Locked = False
Case acSubform
.Locked = False
End Select
End With
Next ctl
frm.AllowDeletions = True
sfrm.Form.AllowDeletions = True
End If
Set ctl = Nothing
Set frm = Nothing
End Sub