By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,662 Members | 1,765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,662 IT Pros & Developers. It's quick & easy.

Help With CheckBox

100+
P: 101
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.checked=true) then
xyz
else
xyz

Like I want to know how can I check that CheckBox Is Clicked before or not.
Thanks.
Feb 11 '08 #1
Share this Question
Share on Google+
6 Replies


Scott Price
Expert 100+
P: 1,384
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
Feb 11 '08 #2

MMcCarthy
Expert Mod 10K+
P: 14,534
If checkbox is named CheckBox1 then in the after update event of the checkbox.
Expand|Select|Wrap|Line Numbers
  1. Private Sub CheckBox1_AfterUpdate()
  2.  
  3.     If Me!CheckBox1 = -1 Then
  4.         Me!ShippingAddress = ""
  5.     Else
  6.         Me!ShippingAddress = Me!BillingAddress
  7.     End If
  8.  
  9. End If
  10.  
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.
Feb 11 '08 #3

100+
P: 101
I was using this code.

Private Sub CheckBox1_AfterUpdate()

If Me!CheckBox1 = checked Then
Me!ShippingAddress = ""
Else
Me!ShippingAddress = Me!BillingAddress
End If

End If
But now its working when I put -1 instead of checked.
Thanks For ur Help.
Feb 11 '08 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
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
Feb 11 '08 #5

100+
P: 101
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.
Feb 11 '08 #6

MMcCarthy
Expert Mod 10K+
P: 14,534
Hey,Thanks for further info.I am sure it will be helpfull in future.
No problem.
Feb 11 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.