1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Access Problem

Discussion in 'Meet and Greet' started by threepicks, Oct 15, 2009.

  1. threepicks

    threepicks Banned

    Joined:
    Oct 14, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Help!

    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?

    Thanks

    Option Compare Database

    Code:
    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
       
       
       Randomize
       num1 = Int((y - x + 1) * Rnd + x)
       num2 = num1 - DiffSet
       
       For i = 13 To z + 13
           Do
               flag = False
               Randomize
               tempnum = Int((y - x + 1) * Rnd + x)
               Tempnum2 = tempnum - DiffSet
               If Tempnum2 < 50 Then flag = True
               
           Loop Until Not flag
                     
       num1 = tempnum
       num2 = Tempnum2
       Next
    End Sub
     
    Last edited by a moderator: Oct 15, 2009
  2. nimesh

    nimesh New Member

    Joined:
    Apr 13, 2009
    Messages:
    770
    Likes Received:
    20
    Trophy Points:
    0
    Occupation:
    Oracle Apps Admin
    Location:
    Mumbai
    Home Page:
    Given the value of z as 11, there is no need for the below code, because all evaluates to false

    Code:
    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
    or
    txtNum2.value = num2

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

Share This Page