Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Select control on a form after calling procedure

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 procedu
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Select control on a form after calling procedure

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)


--
HTH

Bob Phillips

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

"Jake" wrote in message
...
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 procedu
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Select control on a form after calling procedure

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 procedu
Public Sub ValidateWorkingDays(Days As String, Cancel As Boolean)
thanks!
"Bob Phillips" wrote:

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)


--
HTH

Bob Phillips

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

"Jake" wrote in message
...
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 procedu
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Select control on a form after calling procedure

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)



--
HTH

Bob Phillips

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

"Jake" wrote in message
...
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 procedu
Public Sub ValidateWorkingDays(Days As String, Cancel As Boolean)
thanks!
"Bob Phillips" wrote:

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)


--
HTH

Bob Phillips

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

"Jake" wrote in message
...
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 procedu
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass a variable from Form back to calling procedure John[_111_] Excel Programming 4 August 21st 05 03:54 PM
Calling sub procedure Yossi[_2_] Excel Programming 2 August 21st 05 02:01 PM
Calling a procedure in a procedure Norman Jones Excel Programming 8 August 20th 04 07:53 PM
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM
Calling a procedure in a procedure Don Guillett[_4_] Excel Programming 1 August 17th 04 11:31 PM


All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"