Spell Check button issue with subform

S

scott04

Hello everyone,
I have a form that contains validation and inserts into a subform upon
passing validation. I have tried to place a spell check with the code,
DoCmd.RunCommand acCmdSpelling. However my validation code does not work if
there is a miss spelling. Can someone see if maybe the spell check code can
just be added with my validation code?
Dim strMsg As String
If IsNull(Me.Audit_nme) Then
Cancel = True
strMsg = strMsg & "Audit Name required." & vbCrLf
End If
If IsNull(Me.Auditor) Then
Cancel = True
strMsg = strMsg & "Auditor required." & vbCrLf
End If
If IsNull(Me.DateAudit) Then
Cancel = True
strMsg = strMsg & "Date Initiated." & vbCrLf
End If
If IsNull(Me.InitiationReason) Then
Cancel = True
strMsg = strMsg & "Initiation Reason." & vbCrLf
End If
If IsNull(Me.AuditDesc) Then
Cancel = True
strMsg = strMsg & "Audit Scope." & vbCrLf
End If
If IsNull(Me.ImpactedCenters) Then
Cancel = True
strMsg = strMsg & "Centers Impacted." & vbCrLf
End If
If Cancel Then
strMsg = strMsg & vbCrLf & "Correct the entry, or press <Esc> to
undo."
MsgBox strMsg, vbExclamation, "Invalid entry"
End If
Me.frmAuditLifesubform.Requery
Forms!frm_audit.Refresh
 
J

Joshua A. Booker

Scott,

DoCmd.RunCommand acCmdSpelling will spell check the whole form without any
programatic control available.

If you have some text selected on the form, it will spell check only the
selected text. Assuming you only want to spell check certain fields, try
this for each field in your validation rutine:

If IsNull(Me.AuditDesc) Then
Cancel = True
strMsg = strMsg & "Audit Scope." & vbCrLf
Else
With Me.AuditDesc
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
DoCmd.RunCommand acCmdSpelling
End If

This is not tested code so it might need work, but it's a starting point.
There is no way to confirm that spelling got corrected unless you check a
second time. An alternative is to use MS Word automation, but that comes
with overhead and will likely slow down your validation drastically.

HTH,
Josh
 
S

scott04

Josh thanks for help i think i will add the spell check only to the
description field since that is one of the few free form fields
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top