1 textbox populating 2 fields

R

Randy

Access 2000. I have a textbox on my form where I enter the date (6/17/05).
I need a way to automatically enter the numerical month (6) of the date
entered in another field of my table. One data entry two fields
populated...Thanks...Randy
 
A

Andy G

Put this line of code in the AfterUpdate event of the text box with your
date.

anotherField = DatePart("m", textBoxWithDate)

Hope this helps.
Andy G.
 
V

Van T. Dinh

Why would you want to store derived (and hence redundant) in the Table?

If you already store the date value, you can work out the month any time you
need the month so there is no need to store the month.
 
R

Randy

I need the month stored to relate it to another table where only the month
not the date is stored. Please help...
 
R

RuralGuy

Randy said:
I need the month stored to relate it to another table where only the
month not the date is stored. Please help...

Randy,

Van is correct but if you must have the month then:

[tblMonth] = Left(Me.CurrentDate, InStr(1, Me.CurrentDate, "/") - 1)

in the CurrentDate_AfterUpdate event should do it!

If [tblMonth] is a numerical field then you will want:

[tblMonth] = Val(Left(Me.CurrentDate, InStr(1, Me.CurrentDate, "/") - 1))


HTH
 
R

Randy

Thank you Rural Guy, That was the trick.
RuralGuy said:
Randy said:
I need the month stored to relate it to another table where only the
month not the date is stored. Please help...

Randy,

Van is correct but if you must have the month then:

[tblMonth] = Left(Me.CurrentDate, InStr(1, Me.CurrentDate, "/") - 1)

in the CurrentDate_AfterUpdate event should do it!

If [tblMonth] is a numerical field then you will want:

[tblMonth] = Val(Left(Me.CurrentDate, InStr(1, Me.CurrentDate, "/") - 1))


HTH
 
Top