Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input message problem for Date textbox
Dear Sir,
I have a userform with text box "DatePurchase" and other textboxes. when I load my userform and when I entered the data it is working fine, the problem is this when I load the form for date entry and the form is Empty and I want to close my form with close button (unload me) command. it is showing pop up message (input message) "Input must be a date in the format: 'dd/mmm/yyyy" when I enter any date then press the close button then it closing. Pls help me in this regard. I am using the following code. Private Sub DatePurchase_exit(ByVal Cancel As MSForms.ReturnBoolean) If Not IsDate(DatePurchase) Then MsgBox "Input must be a date in the format: 'dd/mmm/yyyy'" Cancel = True Else DatePurchase = Format(DatePurchase, "dd/mmm/yyyy") End If End Sub waiting for response. Regards |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input message problem for Date textbox
Maybe change your If-Then statement to this...
If Not IsDate(DatePurchase) And Len(DatePurchase) 0 Then By the way, my personal preference is to *not* rely on default properties. In my own code, I would always use DatePurchase.Text so I can tell I am looking at the contents of a control and not a simple variable. While the distinction is easy to keep straight when you are writing the code, in six months or a year when you have to come back to maintain (modify) your code, the distinction will be less clear. Oh, and if you work in a job with more than one coder, and if they can be given the job to maintain your code down the line... trust me, they will appreciate your specifically including the property name also. Rick wrote in message ... Dear Sir, I have a userform with text box "DatePurchase" and other textboxes. when I load my userform and when I entered the data it is working fine, the problem is this when I load the form for date entry and the form is Empty and I want to close my form with close button (unload me) command. it is showing pop up message (input message) "Input must be a date in the format: 'dd/mmm/yyyy" when I enter any date then press the close button then it closing. Pls help me in this regard. I am using the following code. Private Sub DatePurchase_exit(ByVal Cancel As MSForms.ReturnBoolean) If Not IsDate(DatePurchase) Then MsgBox "Input must be a date in the format: 'dd/mmm/yyyy'" Cancel = True Else DatePurchase = Format(DatePurchase, "dd/mmm/yyyy") End If End Sub waiting for response. Regards |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input message problem for Date textbox
On May 14, 11:18*am, "Rick Rothstein \(MVP - VB\)"
wrote: Maybe change your If-Then statement to this... If Not IsDate(DatePurchase) And Len(DatePurchase) 0 Then By the way, my personal preference is to *not* rely on default properties. In my own code, I would always use DatePurchase.Text so I can tell I am looking at the contents of a control and not a simple variable. While the distinction is easy to keep straight when you are writing the code, in six months or a year when you have to come back to maintain (modify) your code, the distinction will be less clear. Oh, and if you work in a job with more than one coder, and if they can be given the job to maintain your code down the line... trust me, they will appreciate your specifically including the property name also. Rick wrote in message ... Dear Sir, I have a userform with text box "DatePurchase" and other textboxes. when I load my userform and when I entered the data it is working fine, the problem is this when I load the form for date entry and the form is Empty and I want to close my form with close button (unload me) command. it is showing pop up message (input message) "Input must be a date in the format: 'dd/mmm/yyyy" when I enter any date then press the close button then it closing. Pls help me in this regard. I am using the following code. Private Sub DatePurchase_exit(ByVal Cancel As MSForms.ReturnBoolean) If Not IsDate(DatePurchase) Then MsgBox "Input must be a date in the format: 'dd/mmm/yyyy'" Cancel = True Else DatePurchase = Format(DatePurchase, "dd/mmm/yyyy") End If End Sub waiting for response. Regards- Hide quoted text - - Show quoted text - Hi, Thank you very much, I got the solution. Regards Shahzad |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input message problem for Date textbox
But not quit for me!
The problem is that the focus is on a textbox and when the form is closed bu pressing X-button (upperright corner) the Exit event is happening. In the Exit event I have some code thats validate the entry - and if you won't allow an empty field - you couldn't have a test saying "and Len(DatePurchase) 0" Hope you can help me! Regards, Flemming " wrote: On May 14, 11:18 am, "Rick Rothstein \(MVP - VB\)" wrote: Maybe change your If-Then statement to this... If Not IsDate(DatePurchase) And Len(DatePurchase) 0 Then By the way, my personal preference is to *not* rely on default properties. In my own code, I would always use DatePurchase.Text so I can tell I am looking at the contents of a control and not a simple variable. While the distinction is easy to keep straight when you are writing the code, in six months or a year when you have to come back to maintain (modify) your code, the distinction will be less clear. Oh, and if you work in a job with more than one coder, and if they can be given the job to maintain your code down the line... trust me, they will appreciate your specifically including the property name also. Rick wrote in message ... Dear Sir, I have a userform with text box "DatePurchase" and other textboxes. when I load my userform and when I entered the data it is working fine, the problem is this when I load the form for date entry and the form is Empty and I want to close my form with close button (unload me) command. it is showing pop up message (input message) "Input must be a date in the format: 'dd/mmm/yyyy" when I enter any date then press the close button then it closing. Pls help me in this regard. I am using the following code. Private Sub DatePurchase_exit(ByVal Cancel As MSForms.ReturnBoolean) If Not IsDate(DatePurchase) Then MsgBox "Input must be a date in the format: 'dd/mmm/yyyy'" Cancel = True Else DatePurchase = Format(DatePurchase, "dd/mmm/yyyy") End If End Sub waiting for response. Regards- Hide quoted text - - Show quoted text - Hi, Thank you very much, I got the solution. Regards Shahzad |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input message problem for Date textbox
Well - I should just look a bit further - then I figured it out.
The solution could be ...before the code in the exit-event - you put in If CloseMode = vbFormControlMenu Then Exit sub end if Well i'm still learning ;-) "Flemming Jørgensen" wrote: But not quit for me! The problem is that the focus is on a textbox and when the form is closed bu pressing X-button (upperright corner) the Exit event is happening. In the Exit event I have some code thats validate the entry - and if you won't allow an empty field - you couldn't have a test saying "and Len(DatePurchase) 0" Hope you can help me! Regards, Flemming " wrote: On May 14, 11:18 am, "Rick Rothstein \(MVP - VB\)" wrote: Maybe change your If-Then statement to this... If Not IsDate(DatePurchase) And Len(DatePurchase) 0 Then By the way, my personal preference is to *not* rely on default properties. In my own code, I would always use DatePurchase.Text so I can tell I am looking at the contents of a control and not a simple variable. While the distinction is easy to keep straight when you are writing the code, in six months or a year when you have to come back to maintain (modify) your code, the distinction will be less clear. Oh, and if you work in a job with more than one coder, and if they can be given the job to maintain your code down the line... trust me, they will appreciate your specifically including the property name also. Rick wrote in message ... Dear Sir, I have a userform with text box "DatePurchase" and other textboxes. when I load my userform and when I entered the data it is working fine, the problem is this when I load the form for date entry and the form is Empty and I want to close my form with close button (unload me) command. it is showing pop up message (input message) "Input must be a date in the format: 'dd/mmm/yyyy" when I enter any date then press the close button then it closing. Pls help me in this regard. I am using the following code. Private Sub DatePurchase_exit(ByVal Cancel As MSForms.ReturnBoolean) If Not IsDate(DatePurchase) Then MsgBox "Input must be a date in the format: 'dd/mmm/yyyy'" Cancel = True Else DatePurchase = Format(DatePurchase, "dd/mmm/yyyy") End If End Sub waiting for response. Regards- Hide quoted text - - Show quoted text - Hi, Thank you very much, I got the solution. Regards Shahzad |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
show the input message of a data validation list on a textbox and set editable | Excel Discussion (Misc queries) | |||
A macro to deactivate Input Message textbox without deactivatingError Alert messages | Excel Programming | |||
Display input message in textbox - with merged cells | Excel Programming | |||
Input for TextBox having a mask for date or $ amount | Excel Programming | |||
TEXTBOX - VALIDATE DATE INPUT | Excel Programming |