Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Verify Input

I am using a textboxes in a userform for ordering supplies. I want to check
to see if the quantity entered exceeds the max stock level. The userform is
executed while from Worksheet("Order"). The value for the max stock level
(for this particular medication, is on Worksheet("List") in cell Z3.

I had a macro that I thought would execute AFTERUPDATE. Apparently I am not
doing something right. Not sure if this matters, but the computers that will
be using this have touchscreens and the computer I am writing it on does not.

The user will first enter the ambulance number, then tab, enter, or touch
screen, to advance to the next textbox. Lets say the user enters a value of
5 for Textbox6. The macro should execute, afterupdate, to pull the max stock
level (4) and compare. If 54, then I will clear Textbox6 and setfocus to
textbox6 after displaying a msgbox about the invalid entry.

Any ideas on why it may not be executing, or show me what it should look
like. I am on a different computer to send this message then what my code is
on so I cannot copy and paste.

Thanks,
Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default Verify Input

It would help to see what code you are using now to validate the data - or is
it that you have no code associated with it at all?

If you don't have any code at all associated with it, then this should help:

Private Sub TextBox6_Change()
Dim enteredText As String
Dim maxOrder As Variant

enteredText = Me!TextBox6.Text
maxOrder = ThisWorkbook.Worksheets("List").Range("Z3")
If Val(enteredText) maxOrder Then
MsgBox "You have attempted to over-order. Please try again.", _
vbOKOnly + vbCritical, "Max Order Qty is: " & maxOrder
Me!TextBox6 = ""
Me!TextBox6.SetFocus
Exit Sub
End If
End Sub

Just go to the UserForm in VB Editor and double-click on TextBox 6 and the
code for the _Change() event show appear as a stub with just the first & last
lines of it. Copy the code between the Sub and End Sub statements above and
paste them into the stub in the VBE. Test it out. It should actually test
while typing an entry - so if you typed 5, it would immediately alert, and if
you typed 10, it would alert as soon as you typed the zero.

"WLMPilot" wrote:

I am using a textboxes in a userform for ordering supplies. I want to check
to see if the quantity entered exceeds the max stock level. The userform is
executed while from Worksheet("Order"). The value for the max stock level
(for this particular medication, is on Worksheet("List") in cell Z3.

I had a macro that I thought would execute AFTERUPDATE. Apparently I am not
doing something right. Not sure if this matters, but the computers that will
be using this have touchscreens and the computer I am writing it on does not.

The user will first enter the ambulance number, then tab, enter, or touch
screen, to advance to the next textbox. Lets say the user enters a value of
5 for Textbox6. The macro should execute, afterupdate, to pull the max stock
level (4) and compare. If 54, then I will clear Textbox6 and setfocus to
textbox6 after displaying a msgbox about the invalid entry.

Any ideas on why it may not be executing, or show me what it should look
like. I am on a different computer to send this message then what my code is
on so I cannot copy and paste.

Thanks,
Les

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Verify Input

I have code associated with it. However, the first line I have is:
Private Sub TextBox6_Afterupdate()

What is the difference between Change() and AfterUpdate()?

Thanks for your help. I will switch to Change() and see happens.

Les


"JLatham" wrote:

It would help to see what code you are using now to validate the data - or is
it that you have no code associated with it at all?

If you don't have any code at all associated with it, then this should help:

Private Sub TextBox6_Change()
Dim enteredText As String
Dim maxOrder As Variant

enteredText = Me!TextBox6.Text
maxOrder = ThisWorkbook.Worksheets("List").Range("Z3")
If Val(enteredText) maxOrder Then
MsgBox "You have attempted to over-order. Please try again.", _
vbOKOnly + vbCritical, "Max Order Qty is: " & maxOrder
Me!TextBox6 = ""
Me!TextBox6.SetFocus
Exit Sub
End If
End Sub

Just go to the UserForm in VB Editor and double-click on TextBox 6 and the
code for the _Change() event show appear as a stub with just the first & last
lines of it. Copy the code between the Sub and End Sub statements above and
paste them into the stub in the VBE. Test it out. It should actually test
while typing an entry - so if you typed 5, it would immediately alert, and if
you typed 10, it would alert as soon as you typed the zero.

"WLMPilot" wrote:

I am using a textboxes in a userform for ordering supplies. I want to check
to see if the quantity entered exceeds the max stock level. The userform is
executed while from Worksheet("Order"). The value for the max stock level
(for this particular medication, is on Worksheet("List") in cell Z3.

I had a macro that I thought would execute AFTERUPDATE. Apparently I am not
doing something right. Not sure if this matters, but the computers that will
be using this have touchscreens and the computer I am writing it on does not.

The user will first enter the ambulance number, then tab, enter, or touch
screen, to advance to the next textbox. Lets say the user enters a value of
5 for Textbox6. The macro should execute, afterupdate, to pull the max stock
level (4) and compare. If 54, then I will clear Textbox6 and setfocus to
textbox6 after displaying a msgbox about the invalid entry.

Any ideas on why it may not be executing, or show me what it should look
like. I am on a different computer to send this message then what my code is
on so I cannot copy and paste.

Thanks,
Les

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 verify headers [email protected] Excel Programming 1 October 18th 07 12:38 AM
Verify Input WLMPilot Excel Programming 4 November 1st 06 08:35 PM
verify user input danny_chev Excel Programming 1 August 10th 06 02:54 PM
Verify user input box is a Month End Date mikeburg[_93_] Excel Programming 4 August 4th 06 05:42 PM
Verify information and input a value Richard Excel Discussion (Misc queries) 0 June 22nd 06 09:36 PM


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

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

About Us

"It's about Microsoft Excel"