Automatically populate flag field based on text field

A

Alison

I have a text field that can be filled with "L"; "M"' or "S" to indicated
size of effort. I want to automatically fill my "Work" and "Duration1"
fields based on the entry in the "Size" field.

I've tried If Text1 = L Then Work = 5 but get an error that I can't
understand/fix.

I'm sure there's a VBA way to do this, but don't know where to look next!
Help?
 
M

Mike Glen

Hi Alison,

Try posting on the server newsgroup. Please see FAQ Item: 24. Project
Newsgroups. FAQs, companion products and other useful Project information
can be seen at this web address: http://project.mvps.org/faqs.htm

Mike Glen
Project MVP
 
J

Jan De Messemaeker

Hi,

Alt+F11 to show the VB Editor
Insert, Module
In the Module Code window paste the following (and change it as per your
needs)

sub ForAlison
dim job as task
for each job in activeproject.tasks
if not job is nothing then
if not job.summary then
select case job.text1
case "S"
job.work=
job.duration=
case "M"
job.work=
job.duration=
case "L"
job.work=
job.duration=
end select
end if
end if
next job
end sub

Attention: in VBA Duration and Work are expressed in MINUTES. You can use
Application.hoursperday if you want to express in days

Hoipe this helps,






--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
D

Dean C

I didn't see you repost in developer, so for your "Duration1", try your
actual numbers in the field custom code below. I assumed Large to be a 5 day
task, Medium to be a 3 day task, and small to be a 1 day task.
IIf([Text1]="L",5*480,IIf([Text1]="M",3*480,IIf([Text1]="S",480,0)))
 
A

Alison

Thanks to both Dean and Jan. However, when I debug the code, I immediately
get the same error "Expected:Expression" IF. It seems to have a problem
reading the initial "if"?

Dean C said:
I didn't see you repost in developer, so for your "Duration1", try your
actual numbers in the field custom code below. I assumed Large to be a 5 day
task, Medium to be a 3 day task, and small to be a 1 day task.
IIf([Text1]="L",5*480,IIf([Text1]="M",3*480,IIf([Text1]="S",480,0)))

Alison said:
I have a text field that can be filled with "L"; "M"' or "S" to indicated
size of effort. I want to automatically fill my "Work" and "Duration1"
fields based on the entry in the "Size" field.

I've tried If Text1 = L Then Work = 5 but get an error that I can't
understand/fix.

I'm sure there's a VBA way to do this, but don't know where to look next!
Help?
 
J

Jan De Messemaeker

Hi,

There is no IF, only an IIF.
HTH
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
Alison said:
Thanks to both Dean and Jan. However, when I debug the code, I
immediately
get the same error "Expected:Expression" IF. It seems to have a problem
reading the initial "if"?

Dean C said:
I didn't see you repost in developer, so for your "Duration1", try your
actual numbers in the field custom code below. I assumed Large to be a 5
day
task, Medium to be a 3 day task, and small to be a 1 day task.
IIf([Text1]="L",5*480,IIf([Text1]="M",3*480,IIf([Text1]="S",480,0)))

Alison said:
I have a text field that can be filled with "L"; "M"' or "S" to
indicated
size of effort. I want to automatically fill my "Work" and "Duration1"
fields based on the entry in the "Size" field.

I've tried If Text1 = L Then Work = 5 but get an error that I can't
understand/fix.

I'm sure there's a VBA way to do this, but don't know where to look
next!
Help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top