I want to display 4 numbers between 7.8 and 8.1, that is 7.8 or 7.9, 8.0 or 8.1
I tried the RND function. However, it is not giving the result I need. Tried various combinations.
Need help for the correct syntax.
Thanks,
Alex
I want to display 4 numbers between 7.8 and 8.1, that is 7.8 or 7.9, 8.0 or 8.1
I tried the RND function. However, it is not giving the result I need. Tried various combinations.
Need help for the correct syntax.
Thanks,
Alex
Thanks isladogs. I solved by a clue given in an Excel tutorial.
The syntax is:
Round(Rnd() * 0.3 + 7.8, 1)
Multiplying by the difference and adding by the lowest and rounded to 1 decimal place.
Whilst that may work for you, the expression isn't strictly correct.
The general expression to return a random integer is Int((upperbound-lowerbound+1)*Rnd+lowerbound)
See https://www.w3schools.com/sql/func_msaccess_rnd.asp for an explanation.
Obviously that needs to be modified as you don't want integer values
You should also use the line Randomize beforehand to ensure the 'seed' is reset each time...or you may get the same number sequence every time you run this.
Finally, for info the Round function works differently in Excel and Access
However, the difference only applies to how 'mid-point numbers' such as 1.55, 1.65 are handled so won't matter in your case.