Help With CheckBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • billa856
    New Member
    • Nov 2007
    • 101

    Help With CheckBox

    Hi,
    My Project is in MS Access.
    In that I am using one form for Shipping Entry.
    In That I put One Check Box.
    Now If Shipping Address and Billing Address Are same than I click on that CheckBox.So It will automaticaly enter whatever address entered in Billing Address into Shipping Address.Now uptill this point everything working fine.

    Now I want this thing.
    When I click again on that CheckBox Than it will automaticaly Delete Shipping Address.So If I want to enter Different Shipping Address I can.And If I clicked again after that than it will again automaticaly enter the Billing Address in Shipping Address.But I don't know how to do it?

    In VB we can use (I don't know proper code for VB) something like this
    if(CheckBox1.ch ecked=true) then
    xyz
    else
    xyz

    Like I want to know how can I check that CheckBox Is Clicked before or not.
    Thanks.
  • Scott Price
    Recognized Expert Top Contributor
    • Jul 2007
    • 1384

    #2
    It sounds like you might be better off using the Double-Click event to delete the existing shipping address, otherwise I think you're stuck using a more complicated code routine to first test if the shipping address exists then delete it.

    Regards,
    Scott

    Comment

    • MMcCarthy
      Recognized Expert MVP
      • Aug 2006
      • 14387

      #3
      If checkbox is named CheckBox1 then in the after update event of the checkbox.
      [code=vb]
      Private Sub CheckBox1_After Update()

      If Me!CheckBox1 = -1 Then
      Me!ShippingAddr ess = ""
      Else
      Me!ShippingAddr ess = Me!BillingAddre ss
      End If

      End If
      [/code]

      However, be careful with the code here as it will replace the existing shipping address with billing address when unclicked regardless of whether you wish to overwrite it. I can't imaging this is what you want.

      Comment

      • billa856
        New Member
        • Nov 2007
        • 101

        #4
        I was using this code.

        Private Sub CheckBox1_After Update()

        If Me!CheckBox1 = checked Then
        Me!ShippingAddr ess = ""
        Else
        Me!ShippingAddr ess = Me!BillingAddre ss
        End If

        End If
        But now its working when I put -1 instead of checked.
        Thanks For ur Help.

        Comment

        • MMcCarthy
          Recognized Expert MVP
          • Aug 2006
          • 14387

          #5
          Originally posted by billa856
          I was using this code.



          But now its working when I put -1 instead of checked.
          Thanks For ur Help.
          You're welcome. For future reference, checkboxes have 3 states rather than the two most people think of.

          Checked - Returns -1
          UnChecked - Returns 0
          Neither (This happens when you don't default the checked state of the checkbox to 0) - Returns Null

          Comment

          • billa856
            New Member
            • Nov 2007
            • 101

            #6
            Originally posted by msquared
            You're welcome. For future reference, checkboxes have 3 states rather than the two most people think of.

            Checked - Returns -1
            UnChecked - Returns 0
            Neither (This happens when you don't default the checked state of the checkbox to 0) - Returns Null
            Hey,Thanks for further info.I am sure it will be helpfull in future.

            Comment

            • MMcCarthy
              Recognized Expert MVP
              • Aug 2006
              • 14387

              #7
              Originally posted by billa856
              Hey,Thanks for further info.I am sure it will be helpfull in future.
              No problem.

              Comment

              Working...