Code behaves differently

F

FPS, Romney

Hi all,

I'm using a command button on a subform to spellcheck the text fields on the
page. This works fine on all computers (XP and 97), except for one XP
computer. I'm using a split database, with each computer having its own copy
of the FE.

I compared an XP on which the code works with the XP computer on which the
code does not work.

Both computers have Access 2002 (10.4302.4219) SP-2
Both computers have the same references enabled:
Visual Basic for Applications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft Visual Basic for Applications Extensibility (5.3)

A runtime error occurs on the one XP computer when the command button is
clicked. Choosing "Debug" opens the debug window, highlighting the line
which reads: "If TypeOf ctlSpell Is TextBox And ...".

[No error occurs under normal Debug/Compile of the module]

I'm wondering what could be different about these two XP computers that
would result in this problem occurring on the one, but not the other. Any
help would sure be appreciated.
Thank you.
Mark Davis

(code)

' Adaptation by Terry Wickenden of code
' from Microsoft Knowledge Base
' additional suggestions from Arvin Meyer

Dim ctlSpell As Control

DoCmd.SetWarnings False
On Error Resume Next
' Enumerate Controls collection.
For Each ctlSpell In Me.Controls
If TypeOf ctlSpell Is TextBox And ctlSpell <> "NameID" And ctlSpell <>
"Text132" Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If

End If
Next
Me!cmdSpell.SetFocus
DoCmd.SetWarnings True
 
F

FPS, Romney

Thanks, Dave
I understand that to be a better way of phrasing the code and I thank you
for that. I guess there's no obvious answer to my question regarding why the
existing code works on one XP computer, but not the other?
Mark

Klatuu said:
If ctlSpell.ControlType = acTextBox And ctlSpell.Name <> "NameID" And
ctlSpell.Name <>"Text132" Then
--
Dave Hargis, Microsoft Access MVP


FPS said:
Hi all,

I'm using a command button on a subform to spellcheck the text fields on the
page. This works fine on all computers (XP and 97), except for one XP
computer. I'm using a split database, with each computer having its own copy
of the FE.

I compared an XP on which the code works with the XP computer on which the
code does not work.

Both computers have Access 2002 (10.4302.4219) SP-2
Both computers have the same references enabled:
Visual Basic for Applications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft Visual Basic for Applications Extensibility (5.3)

A runtime error occurs on the one XP computer when the command button is
clicked. Choosing "Debug" opens the debug window, highlighting the line
which reads: "If TypeOf ctlSpell Is TextBox And ...".

[No error occurs under normal Debug/Compile of the module]

I'm wondering what could be different about these two XP computers that
would result in this problem occurring on the one, but not the other. Any
help would sure be appreciated.
Thank you.
Mark Davis

(code)

' Adaptation by Terry Wickenden of code
' from Microsoft Knowledge Base
' additional suggestions from Arvin Meyer

Dim ctlSpell As Control

DoCmd.SetWarnings False
On Error Resume Next
' Enumerate Controls collection.
For Each ctlSpell In Me.Controls
If TypeOf ctlSpell Is TextBox And ctlSpell <> "NameID" And ctlSpell
"Text132" Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If

End If
Next
Me!cmdSpell.SetFocus
DoCmd.SetWarnings True
 
F

FPS, Romney

I don't recall seeing an error code ... just the "End" or "Debug" popup
window.
Your code change works fine on ALL the computers; in fact, it works better
than the original code did even on the machines that completed the
spellcheck routine without producing a runtime error. So, thanks again for
that suggestion.

It was just a curiosity of mine as to why two XP computers with the same
Access version/build numbers, and the same References would behave
differently in response to the same code. (But, no big deal)

Klatuu said:
I dont' know what your runtime error was, so it makes it harder to make a
guess.
It is always helpful when you post a question that involves an error to post
at least the error number. The error description is helpful if you have it.

I really don't know how the code you originally posted runs at all.
--
Dave Hargis, Microsoft Access MVP


FPS said:
Thanks, Dave
I understand that to be a better way of phrasing the code and I thank you
for that. I guess there's no obvious answer to my question regarding why the
existing code works on one XP computer, but not the other?
Mark

Klatuu said:
If ctlSpell.ControlType = acTextBox And ctlSpell.Name <> "NameID" And
ctlSpell.Name <>"Text132" Then
--
Dave Hargis, Microsoft Access MVP


:

Hi all,

I'm using a command button on a subform to spellcheck the text
fields on
the
page. This works fine on all computers (XP and 97), except for one XP
computer. I'm using a split database, with each computer having its
own
copy
of the FE.

I compared an XP on which the code works with the XP computer on whi
ch
the
code does not work.

Both computers have Access 2002 (10.4302.4219) SP-2
Both computers have the same references enabled:
Visual Basic for Applications
Microsoft Access 10.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft Visual Basic for Applications Extensibility (5.3)

A runtime error occurs on the one XP computer when the command button is
clicked. Choosing "Debug" opens the debug window, highlighting the line
which reads: "If TypeOf ctlSpell Is TextBox And ...".

[No error occurs under normal Debug/Compile of the module]

I'm wondering what could be different about these two XP computers that
would result in this problem occurring on the one, but not the
other.
Any
help would sure be appreciated.
Thank you.
Mark Davis

(code)

' Adaptation by Terry Wickenden of code
' from Microsoft Knowledge Base
' additional suggestions from Arvin Meyer

Dim ctlSpell As Control

DoCmd.SetWarnings False
On Error Resume Next
' Enumerate Controls collection.
For Each ctlSpell In Me.Controls
If TypeOf ctlSpell Is TextBox And ctlSpell <> "NameID" And
ctlSpell
"Text132" Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If

End If
Next
Me!cmdSpell.SetFocus
DoCmd.SetWarnings True
 

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