Conditionally format control location

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nickvans
    New Member
    • Aug 2007
    • 62

    #1

    Conditionally format control location

    Hello, and thanks in advance for helping me out. I have a form which filters data in numerous ways. I have set up the form such that Access will only filter a given category if a checkbox next to the control name is checked. Under several categories of data, there are several other options, each with a check box associated with them. I am able to display only the results I want by clicking the check box, but am having difficulty moving the sub-search values to different locations on the form.

    An example: searching for a car.

    [check_box_make] 'makes the next three boxes visible when checked
    [check_box_Chrys ler]
    [check_box_Lexus]
    [check_box_Subar u]

    [check_box_seats] 'makes the next 4 boxes visible when checked
    [check_box_2]
    [check_box_4]
    [check_box_5]
    [check_box_7]

    The goal is to shift the seats check boxes down a specified distance if [check_box_make] is checked. The purpose of this is in my actual form I have so many fields that the user would have to scroll through a bunch of them to get at the categories he/she wants to use.

    When I try to set the Format -> "Top" property in VBA, it moves the object to the top of the form (.0007"). My code looks like this:

    Code:
    Dim startpoint as int
    startpoint = .4
    If [Forms]![frmFrontEnd]![check1].Value <> Yes Then
        [Forms]![frmFrontEnd]![check1].Top = startpoint + 0.5
    End If
    Any help you can offer would be greatly appreciated!

    (PS: the reason I'm not just using combo boxes is because the user will often need to use multiple values in each category.)
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    This is because you are trying to add values in cm (or whatever unit you use) instead of in Twips (1 / 567 cm). In the user interface, the values are converted to and from twips for you. When you use a cm value for twips, the value is so low it looks as if it's zero.
    Last edited by NeoPa; Jan 15 '08, 03:44 PM. Reason: Replaced 1 / 2552 cm with more correct 1 / 567 cm.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Tip :
      Use the current value of Top & Left to vary from where possible. That way there is less code to maintain.

      BTW This will work for you. I use it a fair bit and it's fun :)

      Comment

      • nickvans
        New Member
        • Aug 2007
        • 62

        #4
        Fantastic! Thanks for the help! Its nice of access to let you know that its not going to use the number you give it. Its almost as annoying as it "helpfully" popping up an error message when I leave code as "yadda_yadd a = [" then try to click somewhere else in the code to copy a control. In any case, thank you very much for your help!

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          Not a problem Nick. I hope you enjoy playing as I did ;)

          To be fair to Access though, it is explained (possibly less clearly) in the Help file that the properties are stored in twips.

          Comment

          Working...