Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default User form manipulation


From: "Richard Mogy"
Subject: User Form maneuvering
Date: Thursday, May 06, 2004 6:59 AM

Thanks to those who replied. I apologize for not including the code. I
have used the setfocus command, here's basically what the screen looks like

Enter Start Date:
Enter End Date:
Enter Office:
Enter Start Account:
Enter End Account:

Process End

Using these after updates in the "End Date" and "End Account", if the error
is in the end date, focus goes to "Start Account". If the error is in the
End Account, focus goes to the "END" command button.

Here's the code

Private Sub TxtDateTo_afterupdate()
date1 = Format(TxtFromDate.text, "mm/dd/yyyy")
date2 = Format(TxtDateTo.text, "mm/dd/yyyy")
If date2 < date1 Then
Me.TxtFromDate.SetFocus
TxtDateTo.text = ""
TxtFromDate.text = ""
TxtMessage.text = "End Date must be greater than or equal start date"

End If

End Sub




Private Sub txtEndAccount_afterupdate()
acct1 = txtStartAccount.text
acct2 = txtEndAccount.text

If acct2 < acct1 Or Len(acct2) < 5 Or Len(acct1) < 5 Then
Me.txtStartAccount.SetFocus
txtStartAccount.text = ""
txtEndAccount.text = ""
TxtMessage.text = "End Account must be greater than or equal start
Account"
End If

End Sub



"Richard Mogy" wrote in message
m...
I have created a user form with five text boxes.

The user is asked first to enter two numbers. After the second number is
entered, I check if the second number is greater than or equal to the

first.
If it isn't, then I blank out both boxes, display a message and then I

want
the cursor to go to the first box so the user can re-enter the range.

The problem is getting the cursor back to the first box.

I then have the user enter two dates in the third and fourth box. I do
similar checks to determine that the second date is greater than or equal

to
the first date and if not, blank out both boxes, display a message. I

then
want the cursor to go to the third box.

Any suggestions would be appreciated.





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default User form manipulation

Hi

I suggest you put it in the Exit events instead, there you can use the
Cancel parameter.
Also, allow me to suggest some adjustments in the date assignments, allowing
user entries in all usual date formats:

Private Sub TxtFromDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim date1 As Date
If IsDate(TxtFromDate.Text) Then
date1 = DateValue(TxtFromDate.Text)
TxtFromDate.Text = Format(date1, "mm/dd/yyyy")
Else
TxtFromDate.Text = ""
End If
End Sub

Private Sub TxtDateTo_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim date1 As Date, date2 As Date
If IsDate(TxtFromDate.Text) Then
date1 = DateValue(TxtFromDate.Text)
TxtFromDate.Text = Format(date1, "mm/dd/yyyy")
Else
TxtFromDate.SelStart = 0
TxtFromDate.SelLength = Len(TxtFromDate.Text)
TxtFromDate.SetFocus
End If
If IsDate(TxtDateTo.Text) Then
date2 = DateValue(TxtDateTo.Text)
TxtDateTo.Text = Format(date2, "mm/dd/yyyy")
Else
TxtDateTo.SelStart = 0
TxtDateTo.SelLength = Len(TxtDateTo.Text)
TxtDateTo.SetFocus
End If
If date2 < date1 Then
TxtMessage.Text = "End Date must be greater than or equal start date"
TxtDateTo.SelStart = 0
TxtDateTo.SelLength = Len(TxtDateTo.Text)
Cancel = True

End If
End Sub

HTH. Best wishes Harald


"Richard Mogy" skrev i melding
m...

From: "Richard Mogy"
Subject: User Form maneuvering
Date: Thursday, May 06, 2004 6:59 AM

Thanks to those who replied. I apologize for not including the code. I
have used the setfocus command, here's basically what the screen looks

like

Enter Start Date:
Enter End Date:
Enter Office:
Enter Start Account:
Enter End Account:

Process End

Using these after updates in the "End Date" and "End Account", if the

error
is in the end date, focus goes to "Start Account". If the error is in the
End Account, focus goes to the "END" command button.

Here's the code

Private Sub TxtDateTo_afterupdate()
date1 = Format(TxtFromDate.text, "mm/dd/yyyy")
date2 = Format(TxtDateTo.text, "mm/dd/yyyy")
If date2 < date1 Then
Me.TxtFromDate.SetFocus
TxtDateTo.text = ""
TxtFromDate.text = ""
TxtMessage.text = "End Date must be greater than or equal start date"

End If

End Sub




Private Sub txtEndAccount_afterupdate()
acct1 = txtStartAccount.text
acct2 = txtEndAccount.text

If acct2 < acct1 Or Len(acct2) < 5 Or Len(acct1) < 5 Then
Me.txtStartAccount.SetFocus
txtStartAccount.text = ""
txtEndAccount.text = ""
TxtMessage.text = "End Account must be greater than or equal start
Account"
End If

End Sub



"Richard Mogy" wrote in message
m...
I have created a user form with five text boxes.

The user is asked first to enter two numbers. After the second number

is
entered, I check if the second number is greater than or equal to the

first.
If it isn't, then I blank out both boxes, display a message and then I

want
the cursor to go to the first box so the user can re-enter the range.

The problem is getting the cursor back to the first box.

I then have the user enter two dates in the third and fourth box. I do
similar checks to determine that the second date is greater than or

equal
to
the first date and if not, blank out both boxes, display a message. I

then
want the cursor to go to the third box.

Any suggestions would be appreciated.







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default User form manipulation

Thank you very much. The only think I would have liked would have been if
the cursor had gone to the start date box instead of the end date box, but I
can work with it.
"Harald Staff" wrote in message
...
Hi

I suggest you put it in the Exit events instead, there you can use the
Cancel parameter.
Also, allow me to suggest some adjustments in the date assignments,

allowing
user entries in all usual date formats:

Private Sub TxtFromDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim date1 As Date
If IsDate(TxtFromDate.Text) Then
date1 = DateValue(TxtFromDate.Text)
TxtFromDate.Text = Format(date1, "mm/dd/yyyy")
Else
TxtFromDate.Text = ""
End If
End Sub

Private Sub TxtDateTo_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim date1 As Date, date2 As Date
If IsDate(TxtFromDate.Text) Then
date1 = DateValue(TxtFromDate.Text)
TxtFromDate.Text = Format(date1, "mm/dd/yyyy")
Else
TxtFromDate.SelStart = 0
TxtFromDate.SelLength = Len(TxtFromDate.Text)
TxtFromDate.SetFocus
End If
If IsDate(TxtDateTo.Text) Then
date2 = DateValue(TxtDateTo.Text)
TxtDateTo.Text = Format(date2, "mm/dd/yyyy")
Else
TxtDateTo.SelStart = 0
TxtDateTo.SelLength = Len(TxtDateTo.Text)
TxtDateTo.SetFocus
End If
If date2 < date1 Then
TxtMessage.Text = "End Date must be greater than or equal start date"
TxtDateTo.SelStart = 0
TxtDateTo.SelLength = Len(TxtDateTo.Text)
Cancel = True

End If
End Sub

HTH. Best wishes Harald


"Richard Mogy" skrev i melding
m...

From: "Richard Mogy"
Subject: User Form maneuvering
Date: Thursday, May 06, 2004 6:59 AM

Thanks to those who replied. I apologize for not including the code. I
have used the setfocus command, here's basically what the screen looks

like

Enter Start Date:
Enter End Date:
Enter Office:
Enter Start Account:
Enter End Account:

Process End

Using these after updates in the "End Date" and "End Account", if the

error
is in the end date, focus goes to "Start Account". If the error is in

the
End Account, focus goes to the "END" command button.

Here's the code

Private Sub TxtDateTo_afterupdate()
date1 = Format(TxtFromDate.text, "mm/dd/yyyy")
date2 = Format(TxtDateTo.text, "mm/dd/yyyy")
If date2 < date1 Then
Me.TxtFromDate.SetFocus
TxtDateTo.text = ""
TxtFromDate.text = ""
TxtMessage.text = "End Date must be greater than or equal start

date"

End If

End Sub




Private Sub txtEndAccount_afterupdate()
acct1 = txtStartAccount.text
acct2 = txtEndAccount.text

If acct2 < acct1 Or Len(acct2) < 5 Or Len(acct1) < 5 Then
Me.txtStartAccount.SetFocus
txtStartAccount.text = ""
txtEndAccount.text = ""
TxtMessage.text = "End Account must be greater than or equal start
Account"
End If

End Sub



"Richard Mogy" wrote in message
m...
I have created a user form with five text boxes.

The user is asked first to enter two numbers. After the second number

is
entered, I check if the second number is greater than or equal to the

first.
If it isn't, then I blank out both boxes, display a message and then I

want
the cursor to go to the first box so the user can re-enter the range.

The problem is getting the cursor back to the first box.

I then have the user enter two dates in the third and fourth box. I

do
similar checks to determine that the second date is greater than or

equal
to
the first date and if not, blank out both boxes, display a message. I

then
want the cursor to go to the third box.

Any suggestions would be appreciated.









  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default User form manipulation

Hi

You might try
TxtFromDate.SetFocus
instead of the Cancel = True stuff. If one of them is wrong, who can tell if
it's the From or the To ?

Best wishes Harald

"Richard Mogy" skrev i melding
. com...
Thank you very much. The only think I would have liked would have been if
the cursor had gone to the start date box instead of the end date box, but

I
can work with it.
"Harald Staff" wrote in message
...
Hi

I suggest you put it in the Exit events instead, there you can use the
Cancel parameter.
Also, allow me to suggest some adjustments in the date assignments,

allowing
user entries in all usual date formats:

Private Sub TxtFromDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim date1 As Date
If IsDate(TxtFromDate.Text) Then
date1 = DateValue(TxtFromDate.Text)
TxtFromDate.Text = Format(date1, "mm/dd/yyyy")
Else
TxtFromDate.Text = ""
End If
End Sub

Private Sub TxtDateTo_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim date1 As Date, date2 As Date
If IsDate(TxtFromDate.Text) Then
date1 = DateValue(TxtFromDate.Text)
TxtFromDate.Text = Format(date1, "mm/dd/yyyy")
Else
TxtFromDate.SelStart = 0
TxtFromDate.SelLength = Len(TxtFromDate.Text)
TxtFromDate.SetFocus
End If
If IsDate(TxtDateTo.Text) Then
date2 = DateValue(TxtDateTo.Text)
TxtDateTo.Text = Format(date2, "mm/dd/yyyy")
Else
TxtDateTo.SelStart = 0
TxtDateTo.SelLength = Len(TxtDateTo.Text)
TxtDateTo.SetFocus
End If
If date2 < date1 Then
TxtMessage.Text = "End Date must be greater than or equal start

date"
TxtDateTo.SelStart = 0
TxtDateTo.SelLength = Len(TxtDateTo.Text)
Cancel = True

End If
End Sub

HTH. Best wishes Harald


"Richard Mogy" skrev i melding
m...

From: "Richard Mogy"
Subject: User Form maneuvering
Date: Thursday, May 06, 2004 6:59 AM

Thanks to those who replied. I apologize for not including the code.

I
have used the setfocus command, here's basically what the screen

looks
like

Enter Start Date:
Enter End Date:
Enter Office:
Enter Start Account:
Enter End Account:

Process End

Using these after updates in the "End Date" and "End Account", if the

error
is in the end date, focus goes to "Start Account". If the error is in

the
End Account, focus goes to the "END" command button.

Here's the code

Private Sub TxtDateTo_afterupdate()
date1 = Format(TxtFromDate.text, "mm/dd/yyyy")
date2 = Format(TxtDateTo.text, "mm/dd/yyyy")
If date2 < date1 Then
Me.TxtFromDate.SetFocus
TxtDateTo.text = ""
TxtFromDate.text = ""
TxtMessage.text = "End Date must be greater than or equal start

date"

End If

End Sub




Private Sub txtEndAccount_afterupdate()
acct1 = txtStartAccount.text
acct2 = txtEndAccount.text

If acct2 < acct1 Or Len(acct2) < 5 Or Len(acct1) < 5 Then
Me.txtStartAccount.SetFocus
txtStartAccount.text = ""
txtEndAccount.text = ""
TxtMessage.text = "End Account must be greater than or equal start
Account"
End If

End Sub



"Richard Mogy" wrote in message
m...
I have created a user form with five text boxes.

The user is asked first to enter two numbers. After the second

number
is
entered, I check if the second number is greater than or equal to

the
first.
If it isn't, then I blank out both boxes, display a message and then

I
want
the cursor to go to the first box so the user can re-enter the

range.

The problem is getting the cursor back to the first box.

I then have the user enter two dates in the third and fourth box. I

do
similar checks to determine that the second date is greater than or

equal
to
the first date and if not, blank out both boxes, display a message.

I
then
want the cursor to go to the third box.

Any suggestions would be appreciated.











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
user form Ruth Excel Discussion (Misc queries) 3 October 30th 08 12:51 PM
How do I fill a cell in a user form from a selection on same form? Terry Tipsy Excel Discussion (Misc queries) 4 June 11th 07 02:59 PM
Excel + user input + external data (URL manipulation) [email protected] Excel Discussion (Misc queries) 2 September 28th 06 05:48 PM
I am looking to see if anybody has an equivalant user form to Outlooks CONTACT form BruceJ[_2_] Excel Programming 2 October 15th 03 05:28 PM
User Form SP Excel Programming 2 July 21st 03 11:34 PM


All times are GMT +1. The time now is 07:28 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"