Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Select control on a form after calling procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jake - 24 Sep 2006 22:53 GMT
I have a form that allows users to enter working days for a month in 12 text
boxes and I call a ValidateWorkingDays procedure in the BeforeUpdate event
for each monthly text box.  If user needs to re-enter value I have this code
in my ValidateWorkingDays procedure:
With Me.Days
               .SetFocus
               .SelStart = 0
               .SelLength = Len(Days)
       End With
Days is a string in the ValidateWorkingDays procedure and  I pass the
textbox control text to the procedure e.g. Call
ValidateWorkingDays(txtApril.Text, cancel = False)

I get invalid use of Me keyword in a runtime error.
I don't want to repeat code in each month.  I'm new at this thanks for any
help.
Jake
Bob Phillips - 24 Sep 2006 23:00 GMT
Is Days the argument in the ValidateWorkingDays procedure? If so, Me is not
needed as it should be used in the call

   With Days
               .SetFocus
               .SelStart = 0
               .SelLength = Len(Days.Text)
       End With

and

ValidateWorkingDays(Me.txtApril.Text, cancel = False)

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> I have a form that allows users to enter working days for a month in 12 text
> boxes and I call a ValidateWorkingDays procedure in the BeforeUpdate event
[quoted text clipped - 13 lines]
> help.
> Jake
Jake - 24 Sep 2006 23:18 GMT
I see what you mean.  But I get a runtime error now:
"With object must be user-defined type, object or variant"
Is this because I declared Days as a string in my procedure:
Public Sub ValidateWorkingDays(Days As String, Cancel As Boolean)
thanks!

> Is Days the argument in the ValidateWorkingDays procedure? If so, Me is not
> needed as it should be used in the call
[quoted text clipped - 28 lines]
> > help.
> > Jake
Bob Phillips - 25 Sep 2006 07:16 GMT
Yes that would give an error it should be

Public Sub ValidateWorkingDays(Days As Object, Cancel As Boolean)

or

Public Sub ValidateWorkingDays(Days As MSForms.TextBox, Cancel As Boolean)

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> I see what you mean.  But I get a runtime error now:
> "With object must be user-defined type, object or variant"
[quoted text clipped - 34 lines]
> > > help.
> > > Jake
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.