Go4Expert (http://www.go4expert.com/)
-   Meet and Greet (http://www.go4expert.com/community/meet-and-greet/)
-   -   Access Problem (http://www.go4expert.com/community/access-problem-t19765/)

threepicks 15Oct2009 04:34

Access Problem

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

nimesh 15Oct2009 13:20

Re: Access Problem
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

All times are GMT +5.5. The time now is 14:18.