PDA

View Full Version : Solved: Get the month part from a date in a form



Victor
04-23-2009, 08:20 AM
Hi all:
I have a form in which I enter a date in EfecDate.

Now I create a text box (text276) in which I want to get the month part from
the "EfecDate" (date mm/dd/yyy), but is not working as I expected.

month(EfecDate) where EfectDate is a Date

Also tried month(datevalue(EfecDate))

Please help to fix it.

Thanks for the help.
Victor

CreganTur
04-23-2009, 08:34 AM
Have you tried:
Format(EffectDate, "mm")
That will give you a 2 digit month identifier.

Victor
04-23-2009, 08:58 AM
Randy

I tried your suggestion but do not worked.

Can I get in another place of the same form the month date of a combobox with a format short date?

I want to keep the combobox format what I want is the month part in another place of the form using as source the combobox answer.

The source is a Data type Date/Time field.

Thanks fot the help.

Victor

CreganTur
04-23-2009, 09:22 AM
Can you either show the code that didn't work, or post an example database that shows what you're trying to do?

Victor
04-23-2009, 09:54 AM
Using this code I get the month part but I get the same result in all the forms. I have to run the code again to obtain the corect result in the active form but when move to previous form I see the same result.

Private Sub Text282_LostFocus()
If FecEfecHas > 0 Then
Me.Text282 = Month(FecEfecHas)
End If
End Sub

Thanks for the help.

Victor

CreganTur
04-23-2009, 10:14 AM
Using this code I get the month part but I get the same result in all the forms. I have to run the code again to obtain the corect result in the active form but when move to previous form I see the same result.

You never mentioned anything about multiple forms in your previous posts.

Please provide a specific explination of exactly what you are trying to accomplish.

Victor
04-23-2009, 10:55 AM
Maybe I did not explained correctly.

I should say previous records instead of previous forms

Is only one form but with different records.

In the same form I want get the month part in a textbox I create from a combobox who has a date in it.

Thanks for the help.

Victor

CreganTur
04-23-2009, 11:32 AM
Put the code you created:
If FecEfecHas > 0 Then
Me.Text282 = Month(FecEfecHas)
End If

in your Form's Change event- this will cause the unbound object's value to be updated whenever the data on your form is changed.

Victor
04-23-2009, 12:21 PM
Is there a way to prevent it and only change the record that is active?

I am going to think it over.

Thanks,

Victor

Victor
04-23-2009, 05:11 PM
The solution is to enter the formula in the control source of the text282 textbox as follow:

=Month(FecEfecHas)

Thanks

Victor