Results 1 to 2 of 2
  1. #1
    MarcusM is offline Novice
    Windows 8 Access 2007
    Join Date
    Jul 2017
    Posts
    2

    Toggling checkbox and text box enabled status


    I have the following on a subformate of Order: [textbox]Order Cancelled: [checkbox]When I enter the date , from a date picker, I need the checkbox disabled and also I need the textbox disabled/enabled according to the checkbox value.So far the program is not consistent.Private Sub chckbxOrder_Cancelled_Click() 'Toggle txtDate_Of_Order.Enabled property according to the checkbox status. If (Forms!Order!OrderSubform.Form!chckbxOrder_Cancell ed.Enabled = True) Then txtDate_Of_Order.Enabled = False End If End SubPrivate Sub Form_Current() If (IsNull(Forms!Order!OrderSubform.Form!txtOrder_Num ber.Value) Or _ Forms!Order!OrderSubform.Form!txtOrder_Number.Valu e = "") Then Forms!Order!OrderSubform.Form!txtDate_Of_Order_Num ber.Enabled = True Forms!Order!OrderSubform.Form!chckbxOrder_Cancelle d.Enabled = True ElseIf (IsNull(Forms!Order!OrderSubform.Form!txtDate_Of_O rder.Value) Or _ Forms!Order!OrderSubform.Form!txtDate_Of_Order.Val ue = "") Then Forms!Order!OrderSubform.Form!txtDate_Of_Order.Ena bled = False Forms!Order!OrderSubform.Form!chckbxOrder_Cancelle d.Enabled = True Forms!Order!OrderSubform.Form!chckbxOrder_Cancelle d.Value = True ElseIf (Forms!Order!OrderSubform.Form!chckbxOrder_Cancell ed.Enabled = False) Then Forms!Order!OrderSubform.Form!txtDate_Of_Order.Ena bled = True Else Forms!Order!OrderSubform.Form!txtDate_Of_Order.Ena bled = True Forms!Order!OrderSubform.Form!chckbxOrder_Cancelle d.Enabled = False Forms!Order!OrderSubform.Form!chckbxOrder_Cancelle d.Value = False End IfEnd SubWhen it reaches a blank record it keeps the condition of the last record. E.g.: the last record has the checkbox cancelled and so the textbox is disabled. When I move to a blank record it shows the textbox is disabled even though the checkbox is not checked.I put a breakpoint on the Current event and it does not seem to be working when I click the 'Next' button and land on the last record specifically.Remember this is a form/subform situation and the checkbox and textbox are on the subform.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Maybe something happened when you pasted the code, but it's unreadable. On a new record, the checkbox could be Null, so perhaps you need to test for that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. toggling a popup?
    By Darla in forum Access
    Replies: 1
    Last Post: 09-22-2016, 11:13 AM
  2. Replies: 10
    Last Post: 08-03-2016, 07:17 AM
  3. Toggling Design Mode On/Off
    By Peter Murray in forum Access
    Replies: 3
    Last Post: 09-01-2015, 05:28 PM
  4. Replies: 3
    Last Post: 03-23-2012, 11:21 AM
  5. Checkbox status from combobox
    By justhininabouti in forum Reports
    Replies: 3
    Last Post: 12-06-2011, 02:20 AM

Tags for this Thread

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