Rocky Smolin at Beach Access Software
rockysmolin at bchacc.com
Mon Nov 5 13:55:39 CST 2007
Dan: Here's what I ended up with. My requirement was not as general case as yours. Just to spell check a specific bound field on a filtered form - all records. DoCmd.GoToRecord , , acFirst Do While Me.NewRecord = False Me.TimeEntryNarrative.SetFocus Me.TimeEntryNarrative.SelStart = 0 If Not IsNull(Me.TimeEntryNarrative) Then Me.TimeEntryNarrative.SelLength = Len(Me.TimeEntryNarrative) DoCmd.SetWarnings False DoCmd.RunCommand acCmdSpelling DoCmd.SetWarnings True End If DoCmd.GoToRecord , , acNext Loop SendKeys "{ESC}" The send keys at the end is to cancel the new record. Thanks for the code. Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters Sent: Monday, October 29, 2007 12:18 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Spell Check The code I listed was a little simplified. In my app I have a User Settings form. One of the settings is if a user wants the auto-spellcheck turned on. That value is stored in a tblPeopleMain field, and it's value is True by default. The reason this is only checking a specific field is because all the text in that field is selected in code. I've never tried to run acCmdSpelling without selecting text first! Dan -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at Beach Access Software Sent: Monday, October 29, 2007 2:04 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Spell Check That will definitely help. I'll probably define some hot key to trigger the spell check since the user may want it off - or maybe a check box and use the enter/exit approach. The DoCmd.RunCommand acCmdSpelling if call separately, does that normally run on all the text boxes on the form or just the text box that has the focus? Thanks and regards, Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters Sent: Monday, October 29, 2007 11:49 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Spell Check Hi Rocky, To do spellchecking on textboxes I use this code I've developed through trial & error. It works pretty well - although I've had one 'user' try to paste a long email into a textbox field and then crash the whole database. I retrained him in alternate methods! First, you need to declare a modular variable for each form you'll be using this in like this: Private MvarOriginalText As Variant Second, you need to enter the following into the Enter and Exit events of each textbox (here called memDescription): Private Sub memDescription_Enter() MvarOriginalText = memDescription End Sub Private Sub memDescription_Exit(Delete As Integer) Call SpellCheckField(memDescription, MvarOriginalText) MvarOriginalText = memDescription End Sub Third, put these two procedures into a standard module: Public Sub SpellCheckField(varField As Variant, varOriginalFieldText As Variant) If IsNull(varField) Or varField = "" Then Exit Sub End If If varField = varOriginalFieldText Then Exit Sub End If Call Spellcheck Exit Sub End Sub Public Sub Spellcheck() Dim ctl As Control Dim lngText As Long Dim varFieldContents As Variant Set ctl = Screen.ActiveControl If Not ctl.ControlType = acTextBox Then Exit Sub End If If ctl.Locked = True Then Exit Sub End If If ctl.Enabled = False Then Exit Sub End If ctl.SelStart = 0 ctl.SelLength = Len(ctl.Text) DoCmd.SetWarnings False DoCmd.RunCommand acCmdSpelling DoCmd.SetWarnings True Set ctl = Nothing Exit Sub End Sub This ends up working the way a person would probably intuitively expect automatic spellchecking to work. The user doesn't have to take any action, it just pops up the spellchecking window if something is misspelled, and doesn't do anything at all if all the text is spelled correctly. Hope this helps! Dan -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at Beach Access Software Sent: Monday, October 29, 2007 1:12 PM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Spell Check Dear List: Is there a way through code to trigger the spell checker on a specific field? I think the F7 hotkey does all the fields. MTIA Rocky -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.15.12/1097 - Release Date: 10/28/2007 1:58 PM -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.15.12/1097 - Release Date: 10/28/2007 1:58 PM