Results 1 to 7 of 7
  1. #1
    simjambra is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    4

    Activating a text box using a yes/no check box

    Hello everybody, first post and basic user

    I have a table which stores product license keys for our PCs. I have a yes/no field for each version of software (e.g. Microsoft Office 2010) and a Text field to store the Product License Key.

    Now I am trying to build a nice user-friendly form and I want the check box next to the text box so if the box is selected, the text box is activated and a key can be entered but if it's not, the text field is cleared and de-activated.

    I hope I have explained myself ok and I have asked the question in the right forum.

    Many thanks.



    Si
    Last edited by simjambra; 05-11-2011 at 08:55 AM.

  2. #2
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Hello and welcome to the Forum

    This can be achieved easily to creat a field with yes/no type in your table, and bound the option/check box to the same yes/no field in your form.

    Remember that yes/no field stores 0 and -1 / false and true value to your table.

    Best Regards

    Khalid Afridi

  3. #3
    simjambra is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    4
    Hi Khalid,

    Thanks very much for your response, I have managed to add the boxes which are bound to the yes/no field in the table. Now all I need to do is to activate/deactivate the text field (bound to a different field in the table) depending on the selected check box.

    Is this possible?

    Thanks

    Si

  4. #4
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Yes its possible!

    Alll you have to do is on current envent property of the form:

    do this:

    Code:
     
    if option1.value = -1 then
          textbox1.enabled = true
    else 
          textbox1.enabled = false
    end if
    hope this could help. this is an aircode, sorry if any typo

  5. #5
    simjambra is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    4
    Khalid,

    Thanks I am getting there. I have added the following code to the Current Event of the Form:

    Code:
    Private Sub Form_Current()
    '------------Test
    
    If Officeyn.Value = -1 Then
          Office.Enabled = True
    Else
          Office.Enabled = False
    End If
    
    End Sub
    (Obviously I have renamed the controls according to the name in the properties panel for each control)

    However, the text box remains deactivated regardless of whether the check box is checked or not. Any ideas?

    Thanks again!

  6. #6
    simjambra is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    4
    I have figured it out.

    The activation/deactivation was only happening when the form was loaded. I transferred the code to after update on the check box control and it's working a charm.

    Thanks for your help Khalid.

  7. #7
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Hi Si,
    Glade to see that thread is solved
    Yes! on after update event of the check box the code will work fine, the same code you can keep on current event of the form which will check the True/False values of the Check boxes and will do the desired tasks while you navigate through records on the form.

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

Similar Threads

  1. Replies: 8
    Last Post: 09-26-2011, 06:38 AM
  2. Replies: 3
    Last Post: 11-03-2010, 09:53 AM
  3. To check or Un-Check all Boxes in a form
    By devcon in forum Forms
    Replies: 7
    Last Post: 05-01-2010, 12:03 AM
  4. Replies: 5
    Last Post: 02-10-2010, 12:27 AM
  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