Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246

    Unanswered: Invisible/visible

    Hi,
    I don't know a thing about VB, although I have managed to adapt a few lines of code for some items in my current DB. What I would like is some help in pointing me in the right direction in how to achieve the following.

    I have an area of a form where various fields are held and I want this to remain invisible until the user right clicks in that area. Is this possible and how would I achieve it?

    Regards
    John

  2. #2
    Join Date
    Jan 2004
    Posts
    184

    Re: Invisible/visible

    That is very simple.

    Add a control to the area of the form that you want the user to right-click (let us say a label, you can put a border on the label so the user can see the area). In the Mouse down event of the label

    Private Sub Label_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    if Button=vbRightButton then

    textbox1.visible=true
    textbox2.visible=true
    .
    .
    .
    endif

    End Sub
    In abundance of water only the fool is thirsty. Bob Marley.

  3. #3
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi Rami,
    Thanks very much for this, but I appear to have a problem. I've copied your code and adapted it to mine but have an issue.
    I can still see the area of the form that I require to be invisible and if I right click on that area I get the following error box

    Compile error

    Syntax error


    The code I inserted against the mosue down event on the label was as follows


    Private Sub reveal_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If Button = vbRightButton Then

    reveal1.Visible = True
    reveal2.Visible = True
    .
    .
    .
    End If

    End Sub

    The label in question was called reveal

    Regards
    John

  4. #4
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Can anyone tell me where I'm going wrong?

    Regards
    John

  5. #5
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Ok I think I've solved the error, I got rid of the 3 "." and added an Else statement in with a false value

    But now I want it to re-disappear in they right click again. Any thoughts?

    Regards
    John

  6. #6
    Join Date
    Feb 2004
    Location
    Sydney, Australia
    Posts
    11
    Originally posted by Sticker
    Ok I think I've solved the error, I got rid of the 3 "." and added an Else statement in with a false value

    But now I want it to re-disappear in they right click again. Any thoughts?

    Regards
    John
    John,

    Whilst I am in the same position as you as far as coding and the like is concerned, may I say that in this instance you need to preface the routine with a variable such as a string "show" or "Hide".

    Then the If statement would refer to this variable and depending on it's value ("Show" or "Hide") would make the relevent controls visible or not.

    You have to remember at the end of the routine to change the variable to the opposite of what it was to start so that when you next click the button it has the right value.

    Regards,

    Paul.

  7. #7
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi Paul,
    Thanks for the reply...........................but I'm not at all sure what you mean "preface the routine with a variable such as a string "show" or "Hide" Sorry to be really thick, can you give me a very simple example please.

    Also I'm not clear as to "at the end of the routine to change the variable to the opposite of what it was to start so that when you next click the button it has the right value" Will this be a simple reverse of the code?

    regards
    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •