after i enter a date into a date field (format mm/dd/yyyy) i'd like text box on the same form to respond with the month name and year. for example: i enter 1/1/2009 and the text box should respond January 2009. thanks in advance.
after i enter a date into a date field (format mm/dd/yyyy) i'd like text box on the same form to respond with the month name and year. for example: i enter 1/1/2009 and the text box should respond January 2009. thanks in advance.
Greetings, try this. I have a form with 2 textboxes on it. on the box that will get the date, I set the input mask to "00/00/0000" then on the exit event of that same box I put this sub:
Private Sub Text2_Exit(Cancel As Integer)
Dim dtPartYear
Dim dtPartMonth
'grab the year
dtPartYear = Right(Text2.Value, 4)
'use select case to get the month (first 2 digits) and then test for value
Select Case Left(Text2.Value, 2)
Case Is = "01"
dtPartMonth = "January"
Case Is = "02"
dtPartMonth = "Febuary"
End Select
'assign to the other text box
Text0.Value = dtPartMonth & " " & dtPartYear
End Sub
try it let me know. Works for me. Notice! you will need to do some error checking here though!
O
I only need the month to show in the 2nd field(Month). I've entered the Event as below. If I add "Cancel as Integer" then it give me an error. If I remove that part then it runs but does not populate the 2nd field. What am I missing?
Private Sub DateNotified_AfterUpdate()
Dim dtPartMonth
Select Case Left(DateNotified.Value, 2)
Case Is = "01"
dtPartMonth = "Jan"
Case Is = "02"
dtPartMonth = "Feb"
Case Is = "03"
dtPartMonth = "Mar"
End Select
Month.Value = dtPartMonth
End Sub
I only need the month to show in the 2nd field(Month). I've entered the Event as below. If I add "Cancel as Integer" then it give me an error. If I remove that part then it runs but does not populate the 2nd field. What am I missing?
Private Sub DateNotified_AfterUpdate()
Dim dtPartMonth
Select Case Left(DateNotified.Value, 2)
Case Is = "01"
dtPartMonth = "Jan"
Case Is = "02"
dtPartMonth = "Feb"
Case Is = "03"
dtPartMonth = "Mar"
End Select
Month.Value = dtPartMonth
End Sub
"Month" is a reserved word (and a built in function) in Access and shouldn't be use as object names.
Here is a list of reserved words in Access:
http://allenbrowne.com/AppIssueBadWord.html
Have the after update event of the "DateNotified" text box set the date of the 2nd text box to the same date.i'd like text box on the same form to respond with the month name and year. for example: i enter 1/1/2009 and the text box should respond January 2009.
Then, in the 2nd text box properties, in the FORMAT tab, set the Format property to "mmmm yyyy" (no quotes)
No code, no fuss.