Results 1 to 6 of 6
  1. #1
    mikichi is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    45

    question|how to hide a field in form

    hi,


    i have a check box.
    i want that when i open my form if the check box checked the "ID" field is show and if the check box not checked the "ID" field not show(hide)
    thank you!
    miki

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    You can place VBA code in your form's current event.

    if me.id.value = -1 then

    me.id.visible = true

    else

    me.id.visible = false

    end if

  3. #3
    mikichi is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    45
    Quote Originally Posted by ItsMe View Post
    You can place VBA code in your form's current event.

    if me.id.value = -1 then

    me.id.visible = true

    else

    me.id.visible = false

    end if
    i try this but the code not working for me
    i try also to write this exp:
    Code:
    iif(1=1,[firstName].[Visible]=False,MsgBox(1))
    but it not work too ((

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Use your form's current event. You can create an event handler by going to the form's property window.


    .
    Click image for larger version. 

Name:	PropertyWindow.jpg 
Views:	21 
Size:	66.0 KB 
ID:	14355



    .
    Once you are looking at the form's properties, you can select the "Event" tab and click the Elipses (...) button next to the "On Current" field. Select "Code Builder" This will launch the VBA Editor and you can paste the code in there.

    Code:
    If Me.id.Value = True Then
    Me.firstName.Visible = True
    MsgBox "The value of Id is True"
    Else
    Me.firstName.Visible = False
    MsgBox "The value of Id is False or Is Null"
    End If

  5. #5
    mikichi is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    45
    i know!!!
    but its dont work.
    it is very srange.
    i try to click on three points(...) button behind the current event onLoad.
    its open to me the VBA code editor
    with this function:
    Code:
    private sub myForm onLoad
    end sub
    and i write inside the function msgBox(1)
    but i dont see the msgBox when i open my form
    it is crazy me!
    in other project it is work perfect!
    maybe i off all VBA code in this project?

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    If you want to call a function in your form's load event that is fine. The code I am showing you is to address your question about hiding a control on your form based on a condition. The code I provided uses an If Then statement. If you place that code in the form's current event, it will fire every time the user navigates to a different record. You only need to adjust the code to match the names of your controls

    Me.id will need to be adjusted to match the name of your control that you want to evaluate, ie me.YourControl and Me.firstName to Me.HideThisControl or something...

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

Similar Threads

  1. Calculated Field on form (beginner question)
    By Williams485 in forum Access
    Replies: 21
    Last Post: 02-26-2013, 09:02 AM
  2. Replies: 3
    Last Post: 01-20-2013, 01:14 AM
  3. Form field validation question
    By usmcgrunt in forum Programming
    Replies: 1
    Last Post: 03-19-2012, 04:22 PM
  4. Hide the content of a field
    By peter_lawton in forum Queries
    Replies: 6
    Last Post: 01-17-2012, 11:24 AM
  5. How do i open a form and hide a field?
    By xwnoob in forum Forms
    Replies: 1
    Last Post: 01-05-2012, 03:27 AM

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