calculation within a text box

Swifey

Active Member
Joined
Jan 16, 2003
Messages
421
I am doing a 3 year comparison therefore on my Frontpage Form, I would like to key into a text box the current year/month, then for the 2nd and 3rd year text boxes to automatically calculate a years difference.

For example
Text Box : month = 200402 (Input field)
Text Box : Pend = 200302 (Calculation field)
Text Box : 3end = 200202 (Calculation field)

The Database field name is called Salesperiod, the format: Number: Long Integer, output example 200402. I have tried the subsequent default value formula but I cant get it to work. Could you please help


Code:
Text Box Properties: month = current year/month
Input field

Text Box Properties: Pend  = 2nd year/month
Default Value = IIf([month]>0,([month]-100))

Text Box Properties: 3end = 3rd year/month
Default Value = IIf([pend]>0,([pend]-100))
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I dont see what is wrong. what results are you getting?
I would not use the iif statments just do the calculation and control the value in the first box. You could just set the value of the first box to the current year/month combo and then use validation to make sure that any changes are of an aceptable value.

Peter
 
Upvote 0
I just get blank text boxes.
When I run the 3 queries which look at the three frontpage form text boxes the first query runs which looks at the input field and then returns nothing for the year on year comparison text boxes

Regards
 
Upvote 0
one possibility that comes to mind is that it is treating the data as text rather than a number. try setting the field format to "General Number" and see if that helps

Peter
 
Upvote 0
Unfortunatley I cant change the database field formats they are defined/set by our programers.

Cheers
 
Upvote 0
you can set the formats in your form, that might sort it out. If not you can use a function to do it in the form. cLng() should do it.

HTH

Peter
 
Upvote 0

Forum statistics

Threads
1,221,645
Messages
6,161,044
Members
451,682
Latest member
ogoreo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top