Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    zac123 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    17

    Question show text box if tick box is selected

    hi all,

    i'm ok with finding my way around access but when it come to writing the bits of code i have no idea...



    i basically need a text box which is for date/time to disapear/appear when i tick or untick a little tick box.

    can somone help with that please.

    my tick box is called AlarmResponse and my text box is called CallReceived many thanks
    zac

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    zac123

    You could put the following VBA code in the AfterUpdate event of the checkbox AND in the OnCurrent Event of the form...

    If Me![Checkbox]= -1 then
    Me![textboxName].Visible = True
    else
    Me![textboxName].Visible = False
    end if

    Hope this helps,

    Jim

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,729

  4. #4
    zac123 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    17
    great thanks guys. getting closer...

    does this look right?

    Private Sub After_Update()
    If Me![AlarmResponse] = -1 Then
    Me![CallReceived].Visible = True
    Else
    Me![CallReceived].Visible = False
    End If
    End Sub


    Private Sub Form_Current()
    If Me![AlarmResponse] = -1 Then
    Me![CallReceived].Visible = True
    Else
    Me![CallReceived].Visible = False
    End If
    End Sub

    what seems to happen is the text field is permemantly hidden now.
    zac

  5. #5
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    zac123 -

    Is this code...

    Private Sub After_Update()
    If Me![AlarmResponse] = -1 Then
    Me![CallReceived].Visible = True
    Else
    Me![CallReceived].Visible = False
    End If
    End Sub

    in the after update event of the control named "AlarmResponse"?

    Jim

  6. #6
    zac123 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    17
    yes exactly correct

  7. #7
    zac123 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    17
    i just updated my code to read this but still no joy:

    Private Sub AlarmResponse_AfterUpdate()
    If Me![AlarmResponse] = -1 Then
    Me![CallReceived].Visible = True
    Else
    Me![CallReceived].Visible = False
    End If
    End Sub



    Private Sub Form_Current()
    If Me![AlarmResponse] = -1 Then
    Me![CallReceived].Visible = True
    Else
    Me![CallReceived].Visible = False
    End If
    End Sub

  8. #8
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    zac123

    Unless something changed in AC2007 from AC2003 that I am unaware of...

    I thought this...

    Private Sub After_Update()
    If Me![AlarmResponse] = -1 Then
    Me![CallReceived].Visible = True
    Else
    Me![CallReceived].Visible = False
    End If
    End Sub

    should be...

    Private Sub AlarmResponse_AfterUpdate()
    If Me![AlarmResponse] = -1 Then
    Me![CallReceived].Visible = True
    Else
    Me![CallReceived].Visible = False
    End If
    End Sub

    If the code was in the afterUpdate event of the control. That's why I asked? Also, double check the name of the control.

    Jim

  9. #9
    zac123 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    17
    oh dear this is proving to be very difficult. i tried all those things but still no good. its very strange. Does the defualt value of the tick box matter? currently set to 'No' i tried 0 and 1 to see if it makes any difference.....

  10. #10
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    zac123 -

    If possible, try deleting the default value of the checkBox altogether. Then, test.

  11. #11
    zac123 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    17
    nope, no difference.

    this is a date/time field does that make any difference?

  12. #12
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    zac123 -

    I'm a little confused????

    I thought we were talking about a checkbox?

    What control is a Date/Time field?

    If possible, can you post a copy of the db, less any sensitive data, after completing a compact/repair.

    Thanks,

    Jim

  13. #13
    zac123 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    17
    sorry, dont mean to confuse.

    the text box that we're trying to hide is a date/time field. we're trying to hide it by using the tick box

    i'll upload a copy of the db when i get home.

    thnkas
    zac

  14. #14
    zac123 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    17
    hang on a minute... i think i got it!

    Option Compare Database
    Option Explicit

    Private Sub chk_AlarmResponse_AfterUpdate()
    If Me![chk_AlarmResponse] = -1 Then
    Me![txt_CallReceived].Visible = True
    Me![lbl_CallReceived].Visible = True
    Else
    Me![txt_CallReceived].Visible = False
    Me![lbl_CallReceived].Visible = False
    End If
    End Sub

    Private Sub Form_Current()
    If Me![chk_AlarmResponse] = -1 Then
    Me![txt_CallReceived].Visible = True
    Me![lbl_CallReceived].Visible = True
    Else
    Me![txt_CallReceived].Visible = False
    Me![lbl_CallReceived].Visible = False
    End If
    End Sub
    seems to be working spot on.

    thanks very much

  15. #15
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    zac123

    Glad you got it working!!!

    All the best,

    Jim

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-31-2011, 04:03 AM
  2. Show selected records in subform
    By Papilion in forum Forms
    Replies: 8
    Last Post: 06-18-2011, 07:41 AM
  3. Replies: 1
    Last Post: 08-17-2010, 02:33 PM
  4. Replies: 1
    Last Post: 03-13-2010, 08:38 PM
  5. hide text box till you un-tick check box
    By islandboy in forum Access
    Replies: 14
    Last Post: 09-06-2009, 10:08 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