Monday, October 19, 2009

Ab-normalization at Experts Exchange - part 19

Question today: How do I create a reference to a control in code

The problem:
I have 28 fields on my form named Date1 thru Date28.
I would like to iterate through these controls something like this"

dim n as integer. MyDate as date
n=1
MyDate-Date()
do while n >29
me!Date(n) = MyDate
n=n+1
(increment Mydate by n)
loop

I know it can be done. Just forgotten the syntax. Thanks in advance.

The "answer" by capricorn1:

dim n as integer, myDate as date
myDate=date()
for n=1 to 28
me("date" & n)=mydate
mydate=mydate + 1
next

The response by the questioner CRB1609:
Thanks. You are a star of galactic proportions.

CRB

The real solution would be to ask the questioner why he's using a not normalized date field, but that's a service beyond the "thinking frame" of our EE MS Access expert.
Just keep the questioners unaware of normalization, thus they'll keep coming back.....

Nic;o)
Still proud to be suspended from this "quality site" where wannabee experts rule and "quality" is just another word from the dictionary.
(The question can be found at: http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Coding-Macros/Q_24822375.html )

No comments:

Post a Comment