LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Date Field Problem in Userform


Dear Sir,

I have one userform for data entry. my problem is with the "
DateCharged " field in the userform.

every thing is working fine but when I enter the Month like this:

SEP 08

and press ok to fill out the data to the worksheet, the SEP 08 is
showing the Date like this 08-sep-08 instead of Sep 08

I dont want to show the date in the worksheet.

I want only the month with Year. this is my problem.

Actually I need the month with year like SEP 08, because I have an
other function for Advance Filter, for filtering the records by
month. when I feed
SEP 08 and then press enter key my function filter all the records for
the month of September 08. thats why I need my field show the month
with year in the worksheet.



I am using the following cods in my UserForm.


Private Sub cmdClearForm_Click()
Call UserForm_Initialize
End Sub

Private Sub CommandButton3_Click()
' for ok button
ActiveWorkbook.Sheets("DailyIssue").Activate
Range("A5").Select

' to fill up combo box for the category
If ComboCategory.ListIndex = -1 Then
MsgBox "You must choose the category SHAHZAD"
ComboCategory.SetFocus
Exit Sub
End If
'-----------------------------------------------

' to fill up QTY
If txtQuantity = "" Then
MsgBox " you must provide Quantity "
txtQuantity.SetFocus
Exit Sub
End If

' to fill up Unit price
If txtUnitPrice = "" Then
MsgBox " you must provide Unit Price "
txtUnitPrice.SetFocus
Exit Sub
End If

' to fill up DateIssue
If DateIssue = "" Then
MsgBox " You must enter the date, format: 'dd/mmm/yyyy'"
DateIssue.SetFocus
Exit Sub
End If

' to fill up DateCharged
If DateCharged = "" Then
MsgBox " You must enter the Month, format: 'dd/mmm/yyyy'"
DateCharged.SetFocus
Exit Sub
End If

Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = DateIssue.Value
ActiveCell.Offset(0, 1) = TxtDescription.Value
ActiveCell.Offset(0, 2) = txtQuantity.Value
ActiveCell.Offset(0, 3) = txtUnitPrice.Value
ActiveCell.Offset(0, 5) = ComboCategory.Value
ActiveCell.Offset(0, 6) = ComboEmployee.Value
ActiveCell.Offset(0, 7) = txtTroubleReport.Value
ActiveCell.Offset(0, 8) = DateCharged.Value
ActiveCell.Offset(0, 9) = txtRemarks.Value

' Range("A5").Select



' Ask and Do Procedure
If MsgBox("One record is written, do you have more entries ?",
vbYesNo, "Title") = vbYes Then

Call UserForm_Initialize

Else

Unload Me

End If

End Sub



Private Sub DateIssue_exit(ByVal Cancel As MSForms.ReturnBoolean)
'txtFrom being the text box on the user form where the date is
entered.
' to restrict the date field

If Not IsDate(DateIssue) And Len(DateIssue) 0 Then

MsgBox "Input must be a date in the format: 'dd/mmm/yyyy'"
Cancel = True
Else
DateIssue = Format(DateIssue, "dd/mmm/yyyy")
End If
End Sub



Private Sub DateCharted_exit(ByVal Cancel As MSForms.ReturnBoolean)
'txtFrom being the text box on the user form where the date is
entered.
' to restrict the date field

If Not IsDate(DateCharged) And Len(DateCharged) 0 Then

MsgBox "Input must be a date in the format: 'dd/mmm/yyyy'"
Cancel = True
Else
DateIssue = Format(DateCharged, "mmm/yyyy")
End If
End Sub


Private Sub UserForm_Initialize()

Application.EnableEvents = False

DateIssue.Value = ""
TxtDescription.Value = ""
txtQuantity.Value = ""
txtUnitPrice.Value = ""
ComboCategory.Value = ""
ComboEmployee.Value = ""
txtTroubleReport.Value = ""
txtRemarks.Value = ""
DateCharged.Value = ""
DateIssue.SetFocus
Application.EnableEvents = True

End Sub


Private Sub CommandButton4_Click()

' for cancel buton
Unload Me

End Sub

Private Sub CommandButton5_Click()
Call UserForm_Initialize
End Sub

Private Sub TxtUnitPrice_Exit(ByVal Cancel As MSForms.ReturnBoolean)
' to restrict blank entry
If txtUnitPrice.Text = "" Then
MsgBox "Sorry, please enter the Unit Price to proceed..."
Cancel = True
End If
End Sub

Private Sub txtUnitPrice_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
' to restrict entry for Numbers only
If KeyAscii < Asc("0") Or KeyAscii Asc("9") Then
Interaction.Beep
KeyAscii = 0
End If
End Sub


Private Sub TxtQuantity_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'to restrict blank entry
If txtQuantity.Text = "" Then
MsgBox "Sorry, please enter the Quantity to proceed..."
Cancel = True
End If
End Sub
Private Sub txtQuantity_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
' to restrict entry for Numbers only
If KeyAscii < Asc("0") Or KeyAscii Asc("9") Then
Interaction.Beep
KeyAscii = 0
End If
End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)

' Disable the "X" on the userform so that the user can't
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox Prompt:=" Sorry but I can't let you do that. "
End If
End Sub



 
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
Restriction for the Date Field in UserForm [email protected] Excel Programming 1 May 13th 08 11:03 AM
New date based on one date field minus minutes in another field [email protected] Excel Discussion (Misc queries) 1 December 25th 07 04:05 PM
Another Userform Date Problem Hazel Excel Programming 3 August 13th 07 08:59 PM
Userform date format problem jennie Excel Programming 2 July 30th 04 01:49 PM
Userform Textbox - Date Problem universal[_6_] Excel Programming 2 November 26th 03 04:31 PM


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