G
Guest
Method or Data Member not found for .SetFocus
any suggestions?
any suggestions?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Matt W. said:Method or Data Member not found for .SetFocus
any suggestions?
Matt W. said:This is what she looks like:
If Me.Combo689.Value = "Waived" And IsNull(Me.Comments1) Then
Cancel = True
MsgBox ("Course Waived - Explanation and Who Approved WAIVE, Required
in Comments/Waived Approval Field")
Me.Comments1.SetFocus
End If
Hi, Matt.
As Dirk Goldgar pointed out elsethread, you're getting the compile
error because you're using the same name for the control as you are
for the field. "Me.Comments1.SetFocus" means "use the SetFocus method
of the Comments1 Property of this form." (If the form doesn't have a
Comments1 Property, then Access will use the control of this name.)
Of course, the form _has_ a Comments1 Property, but this property
doesn't have a SetFocus method. However, a text box has a SetFocus
method, but since you didn't tell Access to use the text box control
named Comments1 instead of the form property named Comments1, Access
won't be able to figure out the ambiguity of this name.
To avoid this common bug, either rename every control that the Wizard
creates for you if it is going to be used in VBA code, or in the
Properties dialog window, or in a query, or else always use the bang
operator when referring to controls in VBA code. For example, either
of the following would work:
Me!Comments1.SetFocus
or
Me.txtComments1.SetFocus
. . . where the Wizard-named Comments1 control bound to the Comments1
field is renamed as txtComments1. And I'd also highly recommend
using descriptive names for your controls. If there are hundreds of
controls on a form, it's hard to find, edit and understand code for
combo689, but cboCourseStatus would be much easier on whoever
maintains this database application.
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.