Autoinput form field

  • Thread starter Thread starter dragon power
  • Start date Start date
D

dragon power

Hi!

I need to automatically configure an Access form field based on severa
other fields in the form.

In plain English this is what I want to do.

If field *type*=1 and field *activitydate* is less than or equal t
field *startdate* then I want to automatically set the field *subclass
to pre-start.

HOWEVE

if field *type*=1 and field *activitydate* is greater than or equal t
field *startdate* then I want to automatically set the field *subclass
to post-start.

One small hitch is that the activitydate and the subclass fields are i
a sub report called Activities Subform and the others are all in th
main Activities form.

I thank anyone in advance who helps me with this.

Cheers
Drago
 
Dragon,

Since the value of subclass can apparently always be derived based on
the value of other fields, it is not a good idea to store this value.
If you mean that subclass is a field in a table, I would delete it.
Then, on your form, put an unbound textbox, and in its Control Source
property put...
=IIf([Parent]![type]=1,IIf([activitydate]<=[Parent]![startdate],"pre-start","post-start"),Null)

Note that your post was a little contradictory, as regards when
activitydate=startdate, so I mande an assumption, and also made an
assumption that the calculated control would be empty if type is not 1.
 
Hi Steve!

Thanks for your help in trying to sort this out for me, you have given
me somethign to work on.

Just to explain the seeming contradiction yoe mentioned. Basically the
field I want to auto configure is going to be a drop down box with the
options post start and pre start. So the selection will be one of the
other (or null if there is no start date) depending on whether the
activity date is either before or after the start the date.

So for example: if such and such = A then do this, but if such and such
= B then do that. (Sorry if that was a bit Fisher Price but I have to
say this is all a bit alien to me si I am steering away from being very
technical)

But I'll study the code you so kindly gave me and see if I can work out
how to add the second OTHERWISE option.

Thanks once again for your help Steve
Dragon
 
Dragon,

If I understand you correctly, the expression I gave you will do what
you want. The "contradiction" I was referring to (sorry for not being
clear), was you originally gave the options of ActivityDate >=
StartDate, and ActivityDate <= StartDate, in other words you include the
'equals' situation in both options, which it can only really be in one
or the other. Hope you understand.

The other point I would suggest... if the value of this calculated
control is going to be automatically derived from the existing dates
data, it seems to me that a textbox is better than a combobox... after
all, you will virtually never have to enter this data, since it is
automatically calculated, so the combobox will be no use.
 
Hi Steve

Just thought I would leave you a message to say your suggestion i
working a treat.

Thanks very much mate
 
Back
Top