Hello! I am relatively new to access and definitely new to VBA. I am working on a database that will randomly assign records to one of 3 groups. I have code set up to do this with a 1:1:1 probability, but I need it to be more complex than that. I am hoping to set this up for the probability to base off of specific fields in the database (i.e. if the person is over age 60, they will have a higher probability of being assigned to group 3). There are multiple specific guidelines like this to assess the probability on a person by person basis. The code I have so far is as follows:
Public Function Rand(ByVal Low As Long, _
ByVal High As Long) As Long
Rand = Int((High - Low + 1) * Rnd) + Low
End Function
Private Sub Study_ID_AfterUpdate()
'Randomization Code
If IsNull(Me.Randomizer) Then
Me.Randomizer = Rand(1, 3)
End If
From reading online, it looks like the best way to do this may be to use cases in the public function, but I am really not sure how to or even if what I have is on the right track. I would really appreciate any help I can get on this as I am sort of crunched for time (it is for work and deadlines are approaching).
Thank you!!!