Hello there, I'm pretty much brand new to VBA so please bear with me.
My code appears relatively simple, but it refuses to execute. Code is below. If someone could help me out, I'd be extremely grateful as I've been embarassingly stuck on this for several hours now.
As you can probably tell from the below, the code simply is to execute when a lookup field selects "Physician" or "Teaching Hospital" and then is to either enable or disable a field called "Teaching Hospital Name". The final Else statement is just to ensure that if neither option is selected, the field is disabled by default.
Huge thanks in advance to anyone who reads this. Appreciate your time.
Rob
Option Compare Database
Private Sub Form_Current()
Call RecipientType
End Sub
Private Sub Covered_Recipient_Type_AfterUpdate()
Call RecipientType
End Sub
Private Sub RecipientType()
If Me.Covered_Recipient_Type = "Physician" Then
Me.Teaching_Hospital_Name = Null
Me.Teaching_Hospital_Name.Enabled = False
ElseIf Me.Covered_Recipient_Type = "Teaching Hospital" Then
Me.Teaching_Hospital_Name.Enabled = True
Else
Me.Teaching_Hospital_Name.Enabled = False
End If
End Sub
My code appears relatively simple, but it refuses to execute. Code is below. If someone could help me out, I'd be extremely grateful as I've been embarassingly stuck on this for several hours now.
As you can probably tell from the below, the code simply is to execute when a lookup field selects "Physician" or "Teaching Hospital" and then is to either enable or disable a field called "Teaching Hospital Name". The final Else statement is just to ensure that if neither option is selected, the field is disabled by default.
Huge thanks in advance to anyone who reads this. Appreciate your time.
Rob
Option Compare Database
Private Sub Form_Current()
Call RecipientType
End Sub
Private Sub Covered_Recipient_Type_AfterUpdate()
Call RecipientType
End Sub
Private Sub RecipientType()
If Me.Covered_Recipient_Type = "Physician" Then
Me.Teaching_Hospital_Name = Null
Me.Teaching_Hospital_Name.Enabled = False
ElseIf Me.Covered_Recipient_Type = "Teaching Hospital" Then
Me.Teaching_Hospital_Name.Enabled = True
Else
Me.Teaching_Hospital_Name.Enabled = False
End If
End Sub