Results 1 to 5 of 5
  1. #1
    teirrah1995 is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2010
    Posts
    35

    Invisible/visible box

    Hey, I'm still fairly new to VBA, but I managed to write this poxy bit of code all by myself.

    If Me.Age < 18 Then
    objRectangle.BoxUnders.Visible = False
    Else


    objRectangle.BoxUnders.Visible = True
    End If

    I'm very proud of it, but it doesn't work ^^ I've got some bits and pieces about carers' consent for those under 18, but I want it all hidden under a box I've called "BoxUnders" if they're over.

    Can anyone point out the mistakes I'm making? If not, I'll just disable all the relative fields, but this would be far neater. Thanks.

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    assuming nothing else is broken, i'd go with
    If Me.Age < 18 Then
    Me.objRectangle.BoxUnders.Visible = False
    Else
    Me.objRectangle.BoxUnders.Visible = True
    End If

  3. #3
    teirrah1995 is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2010
    Posts
    35
    That's what I'd started with. I thought the problem was that I wasn't referencing the box properly. But Me. doesn't work either.
    Thanks for the reply.

  4. #4
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    i think i missed something. boxUnders is the name of the box that you will be adjusting. then what is objRectangle? if that's referencing something else, theres your problem. just adjust the .visible attribute of boxunders.

  5. #5
    teirrah1995 is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2010
    Posts
    35
    Oh, no I had objrectangle in place of Me, so now I have Me.boxunders.visible = w/e
    I think this is just messy coding on my part, because Age is worked out from the DOB after update, and this whole thing is afterupdate too. I'll try to use the DOB instead of age.

    Private Sub BoxUnders_AfterUpdate()

    If (((VBA.Date()) - (Me.DOB)) / 365.25) < 18 Then
    Me.BoxUnders.Visible = False
    Else
    Me.BoxUnders.Visible = True
    End If

    End Sub

    That's what I have now. Thanks for replying, but don't worry about it if the answer isn't obvious. I've done this whole form rather poorly.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Setting fields visible/invisible
    By col5473 in forum Forms
    Replies: 1
    Last Post: 09-17-2010, 09:14 AM
  2. Combo Boxes Visible/Invisible
    By Rick West in forum Forms
    Replies: 2
    Last Post: 07-06-2010, 09:41 AM
  3. Replies: 5
    Last Post: 01-29-2010, 11:09 AM
  4. Invisible LookUp Data List
    By aaghd in forum Access
    Replies: 3
    Last Post: 07-28-2009, 02:35 PM
  5. Tab only visible when field = x
    By ecpike in forum Forms
    Replies: 7
    Last Post: 06-08-2009, 04:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums