Exit Spelling Checker if Status is Closed (1 Viewer)

billgyrotech

Banned
Local time
Today, 04:43
Joined
Apr 18, 2013
Messages
258
Hello,


I have a spelling checker (thanks to Missinglinq) that goes to error when the Status field on my form is "Closed" which makes the record read only.


Can there be an "If" statement to exit if the Status field on my form is "Closed"?


Thank you,
Bill


Code:
Public Function SpellChecker()

Dim ctrl As Control
Dim frm As Form
Set frm = Screen.ActiveForm
DoCmd.SetWarnings False
For Each ctrl In frm.Controls
 
 If TypeOf ctrl Is TextBox Then
   If Len(ctrl) > 0 Then
     With ctrl
      .SetFocus
      .SelStart = 0
      .SelLength = Len(ctrl)
     End With
     
     DoCmd.RunCommand acCmdSpelling
       
   End If
 End If

Next

DoCmd.SetWarnings True

End Function
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:43
Joined
May 7, 2009
Messages
19,233
maybe add another condition:
Code:
If TypeOf ctrl Is TextBox Then
   If Not ctrl.enabled Or ctrl.Locked Then
   If Len(ctrl) > 0 Then
     With ctrl
      .SetFocus
      .SelStart = 0
      .SelLength = Len(ctrl)
     End With
     
     DoCmd.RunCommand acCmdSpelling
       
   End If
   End If
 End If
 

billgyrotech

Banned
Local time
Today, 04:43
Joined
Apr 18, 2013
Messages
258
Thanks but I still get the popup:


Run-time error '2046':


The command or action 'Spelling' isn't available now.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:43
Joined
May 7, 2009
Messages
19,233
sorry, so before calling the SpellCheck() function on the Click event of a button or any Special key, test if field status is "Closed"
Code:
If Trim(Me.yourFieldStatus  & "") <> "Closed" Then
    Call SpellChecker()
End If
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:43
Joined
May 7, 2009
Messages
19,233
you're welcome sir.
 

Users who are viewing this thread

Top Bottom