1 textbox populating 2 fields

  • Thread starter Thread starter Randy
  • Start date Start date
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
 
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.
 
I tried the code as suggested, but nothing happened. I also tried another
code I picked up earlier, didn't work. Here's what I tried in the
AfterUpdate event of my "CurrentDate" textbox. Any other
suggestions?..Thanks

tblmonth = DatePart("m", CurrentDate)
tblmonth = Month(Current_Date)
 
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.
 
I need the month stored to relate it to another table where only the month
not the date is stored. Please help...
 
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
 
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
 
Back
Top