Results 1 to 7 of 7
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862

    .Visible is going wrong or Prevalue is not set?

    I have a Radial button that I am trying to set up so wneh selected another field pops up. With the following it works if I select twice as the other field alwats shows upon opening the form:

    I am trying to set the default value of NIE without going into the Design view of the Table or Form.

    Private Sub NIE_Default_Click()
    If Me![NIE_Default] = True Then
    Me![NIE].Visible = True
    Else


    Me![NIE].Visible = False
    End If
    End Sub

    I would prefer to use a button though. I do think I can relate this same code to a button and have it work.

    Where is it going wrong?

    Thanks
    T

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    What is "a Radial button"? Do you mean a option button?

    If so, you could use"
    Code:
    Private Sub NIE_Default_Click()
        Me![NIE].Visible = Not Me![NIE].Visible
    End Sub

    I am having a hard time understanding what you are asking. Need more details.

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Not sure of your intentions here! Try this: Of course you will need a Me.Requery and Me,Dirty = False using the OnClickEvent of the button and of course the main code needs to be on the OnCurrentEvent.

    If Me.NIE = -1 Then
    Me.NIE.Visible = False
    Else
    Me.NIE.Visible = True
    End If
    HTH

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Guess I was too slow Steve! Better option is yours anyway.

  5. #5
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    ssnafu,
    Thanks. You version is shorter, but gives the same result.

    I am trying to set the default value of NIE field without going into the Design view of the Table or Form. So I am wanting the NIE Field lookup to be not visible until the the radial/button is selected. Once the value is entered, then the NIe field Lookup disappears. If there is an easier way, please advise. Otherwise the user will need to edit the list that pops up.

    thanks

  6. #6
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    Works best for me:

    Private Sub NIE_Beforeupdate()
    Me![NIE].Visible = False
    End Sub
    Private Sub NIE_Default_Click()
    Me![NIE].Visible = Not Me![NIE].Visible
    End Sub

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You can set the default value of a form or control, but to save that value, you have to set it in design view.

    One option is to have a table with one field to store the value you want as the default and use VBA to read/write the value to the control/table.

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

Similar Threads

  1. Replies: 30
    Last Post: 07-21-2014, 02:46 PM
  2. Visible/Not Visible based on condition VBA
    By BLFOSTER in forum Programming
    Replies: 3
    Last Post: 07-15-2014, 01:29 PM
  3. Replies: 2
    Last Post: 01-06-2011, 04:38 AM
  4. variable NOT visible -Please help
    By iamraja5 in forum Programming
    Replies: 10
    Last Post: 11-07-2010, 11:02 AM
  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