Thank you.
ReferralID is the field before the doctor/nurse grade combo that is causing the error.
Private Sub ReferralID_AfterUpdate()
Select Case ReferralID
Case 1
PAROnRef.Enabled = False
PAROnRef.Value = -1
DocNurseGrdID.Enabled = False
fraPostITU.Enabled = True
Case 2
DocNurseGrdID.Enabled = True
PAROnRef.Enabled = True
fraPostITU.Enabled = False
PostITU.Value = 3
Case Else
DocNurseGrdID.Enabled = False
DocNurseGrdID.Value = Null
PAROnRef.Enabled = True
fraPostITU.Enabled = False
PostITU.Value = 3
End Select
End Sub
'Refresh doctor / nurse grade combo box
Private Sub DocNurseGrdID_AfterUpdate()
Me.Refresh
End Sub
Private Sub Form_Current()
'ON CURRENT EVENT
Me.DocNurseGrdID.Enabled = False
'Enable doctor / nurse grade if referral source is Doctor /
'Nurse and disable / enable PostITUHDU frame depending on
'value
Select Case ReferralID
Case 1
PAROnRef.Enabled = False
DocNurseGrdID.Enabled = False
fraPostITU.Enabled = True
Case 2
DocNurseGrdID.Enabled = True
PAROnRef.Enabled = True
fraPostITU.Enabled = False
Case Else
DocNurseGrdID.Enabled = False
PAROnRef.Enabled = True
fraPostITU.Enabled = False
End Select
End Sub
Private Sub Form_Open(Cancel As Integer)
Call fAllowEdits(Form)
Me.Refresh
DoCmd.Maximize
Me.Refresh
End Sub
Private Sub Form_Load()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Requery
End Sub
Allow edits is a function to give certain users read-only or full access.
Public Sub fAllowEdits(frm As Form)
Dim ctl As Control, db As Database, r As Recordset
Dim Lev As Integer, intCanEdit As Integer, Nme As String, frmName As String
Set db = CurrentDb
Set r = db.OpenRecordset("tblUsers")
'msgbox "Current form is " & frm.Name
Call fOSUserName2
Nme = fOSUserName2
Do While Not r.EOF
If Nme = r.Fields("Username") Then
Lev = r.Fields("LevelID")
End If
r.MoveNext
Loop
If Lev = 2 Then
intCanEdit = False
Else
intCanEdit = True
End If
If intCanEdit = False Then
With frm
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acComboBox, acTextBox, acListBox, acSubform, acCheckBox, acOptionButton
ctl.Locked = True
Case acCommandButton
If ctl.Name = "cmdDelete" Or ctl.Name = "cmdAddNew" Or ctl.Name = "cmdAdd" Then
ctl.Enabled = False
End If
End Select
Next ctl
Else
With frm
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acComboBox, acTextBox, acListBox, acSubform, acCheckBox, acOptionButton
ctl.Enabled = True
ctl.Locked = False
If ctl.Name = "txtunitno" Or ctl.Name = "txtptname" Or ctl.Name = "txtptname2" Or _
ctl.Name = "txtptdob" Or ctl.Name = "txtdiagopid" Or ctl.Name = "txtstatus" Or _
ctl.Name = "txtCons" Or ctl.Name = "txtConsChange" Then
ctl.Enabled = False
ctl.Locked = True
End If
Case acCommandButton
ctl.Enabled = True
End Select
Next ctl
End If
End Sub