AdmiralJonB
New member
- Local time
- Today, 22:12
- Joined
- Nov 23, 2004
- Messages
- 7
I'm trying to create some vb code to create some kind of validation so i can check whether a number inputted is 1dp and to a half e.g. 0.0, 0.5, 1.0, 1.5 etc. This is for a form btw.
I've tried with the standard validation settings but i can't find a way to do this. I have some code which i made for it but it's either not working properly or i haven't got it running at the right place.
What I've tried to do, as for some reason when using 'MOD 0.5' it tries to divide by 0, i multiplied it by two so any 0.5 numbers would become integers so could be divisible by 1 with no remainder (I think MOD is the right command to use).
The final thing is where to put the code. I've tried a few things but for some reason it doesn't come up with a message box at all. Would this type of code stop the user from moving to another field?
BTW, one last question. Is there a way to clear all the records from the database and start all autonumbers from the beginning?
I've tried with the standard validation settings but i can't find a way to do this. I have some code which i made for it but it's either not working properly or i haven't got it running at the right place.
Code:
Dim Validate1 As Integer
Validate1 = WeightWanted.Value * 2
If Validate1 Mod 1 = 0 Then
Else: MsgBox ("The Value must be to the closest half a kg")
End If
What I've tried to do, as for some reason when using 'MOD 0.5' it tries to divide by 0, i multiplied it by two so any 0.5 numbers would become integers so could be divisible by 1 with no remainder (I think MOD is the right command to use).
The final thing is where to put the code. I've tried a few things but for some reason it doesn't come up with a message box at all. Would this type of code stop the user from moving to another field?
BTW, one last question. Is there a way to clear all the records from the database and start all autonumbers from the beginning?