Results 1 to 3 of 3
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Choose One Value, not two, one disabled if other enabled.

    I have e fields on my form, one named txtFreightCharge that is a textbox and is used for Freight and Handling Charges
    The other is a checkbox that when checked applies the customers standard freight charge. It is named ApplyShipRate

    I want one or the other to be able to be used, not both. If users checks checkbox and the tries to update textbox, it will be disabled and reversed for the other option. If user chooses to add their own value using the textbox, then the checkbox will be disabled until they clear the textbox with a messagebox that they cant use both.

    I am trying something like this but unsure of how to add the message box about they cant use both.

    If Me.txtFreightCharge.Value > 0 Then 'User chooses their own Freight Charge
    Me.ApplyShipRate.Enabled = False
    Else
    Me.ApplyShipRate.Enabled = True
    End If

    If Me.ApplyShipRate = True Then 'User chooses to apply Customers ship rate
    Me.txtFreightCharge.Enabled = False
    Else
    Me.txtFreightCharge.Enabled = True
    End If

    ___________________________________
    Code that is used if user clicks on ApplyShipRate;
    Private Sub ApplyShipRate_AfterUpdate()
    If ApplyShipRate = False Then ' Set Freight To Zero
    [FreightCharge] = 0
    Me.Requery
    End If
    If ApplyShipRate = True Then ' Set Taxes To Customers ShipRate
    [FreightCharge] = [Text133] * [txtOrderSubtotal] 'Text133 is Customers Freight Charge Rate
    Me.Requery
    End If
    End Sub

    I forgot, code should set ApplyShipRate to null; Here is code for txtFreightCharge

    Private Sub txtFreightCharge_AfterUpdate()
    Me.Label135.Visible = True ' Label for ApplyShipRate


    Me.ApplyShipRate.Enabled = True 'Checkbox is enabled
    Me.ApplyShipRate = Null 'checkbox is set to null,i.e. unchecked.
    End Sub
    Attached Thumbnails Attached Thumbnails Example.jpg  
    Last edited by burrina; 11-21-2012 at 11:31 AM. Reason: Forgot something

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Try:
    Code:
    If Me.txtFreightCharge.Value > 0 Then 'User chooses their own Freight Charge
        If Me.ApplyShipRate = True Then
            MsgBox "Cannot use both Freight entry and Apply Shipping"
            Me.ApplyShipRate = False
        End If
        Me.ApplyShipRate.Enabled = False
    Else
        Me.ApplyShipRate.Enabled = True
    End If
    If Me.ApplyShipRate = True Then 'User chooses to apply Customers ship rate
        If Me.txtFreightCharge.Value > 0 Then
            MsgBox "Cannot use both Freight entry and Apply Shipping"
            Me.txtFreightCharge.Value = Null
        End If
        Me.txtFreightCharge.Enabled = False
    Else
        Me.txtFreightCharge.Enabled = True
    End If
    Your code will be easier to read if you indent and then use code tags for posting to retain indents.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Thanks, I will try and do that next time. Right now I would say that I am pulling my hair out if I had any. My birthday present to myself was Access 2010 and It is driving me crazy. All my calendars are gone, date picker will not work. Thanks again Microsoft!!!

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

Similar Threads

  1. Replies: 20
    Last Post: 06-04-2012, 11:48 AM
  2. Replies: 7
    Last Post: 11-20-2011, 08:34 PM
  3. disabling an enabled button that has been clicked.
    By aaron47 in forum Programming
    Replies: 3
    Last Post: 08-26-2011, 09:49 AM
  4. Enabled = False
    By Juan4412 in forum Forms
    Replies: 2
    Last Post: 04-19-2011, 06:05 PM
  5. Replies: 4
    Last Post: 09-10-2009, 03:09 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