manipulating data from one text box to another

john doe the 3rd

New Member
Joined
Mar 13, 2004
Messages
47
hi guys im having some trouble with a form and need some vb to carry out this specific function.


i have a text box, that is blank
i have another text box which has some code behind it which works out some units for me, but im having some trouble getting this information, manipulating it and placing it into the blank text box. example:


text box 1 has some information - the number of "credits" achieved by astudent over a term.

text box 2 is blank .

i would like text box 2 to divide the value of text box 1 by 10 and place the answer in itself , so now text box 2 has the answer to textbox1 / 10

but.. i ONLY want textbox 2 to divide the value of textbox 1 by 10 when the value of textbox 1 is a multiple of 360. so thats 360, 720, 1080 etc.



thanks. :eek:
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Have a look at the MOD function in Access. Can't remember the syntax (it's different from the Excel syntax) but if MOD(somevalue,360)=0, then somevalue is a multiple of 360.
Use the Expression Builder to get the correct syntax -- something like
IIF(TheModFunctionGoesHere,[text1]/10,0) where [text1] is the first field you mentioned.

Denis
 
Upvote 0
What a coincidence - I was looking for an Access modulus function tonight but in the absence of finding anything I reverted to another method that I used some years ago - this method may or may not help you. The modulus function I used looked like this :

Iif([Numerator]/[Denominator]=Round([Numerator]/[Denominator],0), "if statement", "else statement")

Inserting this into the formula from Denis, it would look something like this :

Iif([text1]/360=Round([text1]/360,0), [text1]/10, 0)

HTH, Andrew. :)
 
Upvote 0
Andrew, thanks for the comment and the alternative approach. I found the MOD feature -- in Access and VBA it's an operator, not a function.
Syntax is --
IIF([MyField] mod 3 =0,[MyField],0)

Denis
 
Upvote 0
Thanks for the explanation Denis - I couldn't work out how to use the MOD operator in Access so I had to make up my own way of doing it.

Cheers, Andrew. :)
 
Upvote 0
hi guys thanks for the useful response, however still a bit lost, never used "mod" before , i assume i must make an expression from the properties of the blank textbox 2 , is this correct?
 
Upvote 0
Hi, yes you need to make an expression. In design view on the form, right-click Text2 and select Properties. In the Control Source row, enter the expression: =IIF([Text1] mod 360 =0,[Text1],0)

Denis
 
Upvote 0
nice one , just needs some modification had a go but i cant seem to get it right you gave me the following expression


Code:
=IIf([text1] Mod 360=0,[text1],0)



which i place in the text2 control source, but how do i modify this expression to basically say the following:

IF text1 total = 360 (or multiple of 360) , text2 = 36 ( or whatever is in text1 divided by 10)

so basically this is what im trying to achieve :

Code:
If       text 1 =  360        then             text2 =  36
If       text 1 =  720        then             text2 =  72
If       text 1 =  1080      then             text2 =  108
If       text 1 =  1440      then             text2 =  144




cheers
(y)
 
Upvote 0
nice! thank you .


for the sake of me being more complicated ( sorry guys ) just wondering if this could be adopted for use with a timer that is counting up. so same again but this time

text1= timer counting up
text2 = blank,

when timer reaches 360, 36 appears in the blank box. i tried using the above code with the timer and it works until the timer reaches 360, but at 361 seconds the text2 sets back to zero until 720 when it displays 72. can i somehow store the last value of 36 until the timer reaches 720 and replaces this value , and then again the 72 is stored until the next multiple value replaces it. i am guessing i will need to you the After_update feature? to store the previous value? :pray:
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,248
Members
451,756
Latest member
tommyw

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