Access Problem

threepicks's Avatar
Email Reported As Spam

I would like to design a custom form as follows:
My software is Access 2007

Three columns of 12 rows each are needed. One for num1, 1 for num2, and a third named diffSet.
The DiffSet column will contain 12 constant numbers of any arrangement.

I am unable to get my form to show the columns of numbers. Anyone have any idea how to do this?


Option Compare Database

Sub Unique_Numbers()
   Dim x As Long, y As Long, z As Long, tempnum As Long, Tempnum2 As Long
   Dim flag As Boolean
   Dim i As Integer
   x = 50
   y = 660
   z = 11
   If z = 0 Then Exit Sub
   If z > 50 Then z = 50
   If z > y - x + 1 Then
   Exit Sub
   End If
   num1 = Int((y - x + 1) * Rnd + x)
   num2 = num1 - DiffSet
   For i = 13 To z + 13
           flag = False
           tempnum = Int((y - x + 1) * Rnd + x)
           Tempnum2 = tempnum - DiffSet
           If Tempnum2 < 50 Then flag = True
       Loop Until Not flag
   num1 = tempnum
   num2 = Tempnum2
End Sub

Last edited by shabbir; 15Oct2009 at 10:18.. Reason: Code blocks
nimesh's Avatar, Join Date: Apr 2009
Invasive contributor
Given the value of z as 11, there is no need for the below code, because all evaluates to false

If z = 0 Then Exit Sub
If z > 50 Then z = 50
If z > y - x + 1 Then
Exit Sub
End If
Also I see that you are just storing the values in variables num1 and num2
You are not assigning it to any controls on the form

like lblNum1.text = num1
txtNum2.value = num2

Also you have not defined the variables num1 and num2
it could be a problem if option explicit is turned on