Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get a number under a condtion?

Status
Not open for further replies.

wdacc

Technical User
Aug 12, 2002
33
0
0
US
Could I know how to get a number under such condition? eg. X=Y+D. when Y=0, X=Y=0, In other words, when Y=0, I want X=0. When Y is non zero number, I need X=Y+D. I'll appreciate help.
 
uhh, you just want to fill say a textbox with this value? you could do it easily using VBA, let me know if this makes any sense.
 
JimbOne,

If a user can use that, that will be great! Do you think it is OK for one input VBA code if he didn't learn that before?
 
yeah its ok, the only way you can start to learn. so basically you could have 3 unbound textboxes on your form. 2 of them would be Y and D, and the 3rd, the result textbox would be X. Name theses textboxes TXTY, TXTX and TXTD. Place a command button on your form, right click the command button, click "build expression" then select "Code Builder".

Place the following code in the area which you're taken to(should be a procedure called "Command1_Click")

if txtY.value = 0 then
TxtX.value = 0
else
txtx.value = txty.value + txtD.value
end if

that will accomplish what you wanted above. let me know how it works.

 
And what about the Iif function, like this:
X = Iif(Y = 0, 0, Y + D)

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
PHV,

Origianl expressionis like this "Text Box:Gaylord"

Control Source =((([Units / Gaylord]/10)*[10PartsWtinGaylord])/453.6+[AccessoryWeight])

Now I'd to have Gaylord =0 when [10PartsWtinlord]=0, otherwise Gaylord==((([Units / Gaylord]/10)*[10PartsWtinGaylord])/453.6+[AccessoryWeight])

Could you help me with that ?
 
PHV,

I got what I want. Thanks you very much !!!
 
Hi, expert, Last time I want any digit becomes 0. So I got help from PHV. Indeed the statment (([PackageCount]*[Packages/Case])\10)*10 is very useful.

Now I'd like to have special condition, that is if last digit is 9, I want add 1. For example if it is 999, I want it to be 100. Could someone give me detailed formula for that? Thanks!!!
 
Try this:
((1+([PackageCount]*[Packages/Case]))\10)*10

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top