How do I set up a check box?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have a "customer's online order" database, in one of the form, i have
"billing info" & "shiping info", most customer's billing address are also the
shiping address, to provent miss typing or type in wrong info, i'm trying to
set up a check box, when i check that box, means the billing info as same as
shiping info, could someone help me, thank you.
 
Carol,
Since you need the Shipping fields anyway (when Ship <> Bill) just place a small button
on the form that copies the Bill info to the Ship fields.
Name it cmdCopyBillToShip, and use a Caption of &CopyBilling. (now Alt-C will cause
the code to run as well as a mouse click)

Use the On Click event of the Button for your code. (use your own field names)

BillName = ShipName
BillAddress1 = ShipAddress1
BillCity = ShipCity
etc... for all your address fields.
 
Carol Shu said:
i have a "customer's online order" database, in one of the form, i have
"billing info" & "shiping info", most customer's billing address are also the
shiping address, to provent miss typing or type in wrong info, i'm trying to
set up a check box, when i check that box, means the billing info as same as
shiping info, could someone help me, thank you.

The way I handle this would be to add a YES/NO field to your table, such as,
SAMEASSHIPPING. Then add this check box to the form and on the AfterUpdate
Event of the checkbox use something like :

If Me.SAMEASSHIPPING Then
Me.BillingAddress1 = Me.ShippingAddress1
Me.BillingState = Me.ShippingState
etc....
End If
 
Thank you.
I used the on click event, also used my own field name, and then all fields
just went blank.lol. help me please.
 
Thank you. I used add a YES/No to the table, and used the afterupdate event,
when i check the YES box, it took me back to the code and says " compile
error: expected end sub", why
 
Carol

You have to compile the code first. Select "Debug/Compile" from the top menu
of the MS Visual Basic screen. Tell us what error messages you are getting.
 
**Please show the "exact" code you used...
AND, where did you place that code. (describe exactly)

Have you done Event Procedures before?
If not...

Select the button in Design mode.
In it's Properties, find the OnClick event, and place your cursor in that field.
Using the down arrow on the right of that field, click it and select EventProcedure.
Now click the little box on the right with 3 dots (...)
You should see this...

Private Sub cmdYourButtonName_Click()

End Sub

Your code should be placed between those 2 lines.

Private Sub cmdYourButtonName_Click()
ShipName = BillName
ShipAddr = BillAddr
Ship City = BillCity
(etc... for all your fields Bill fields)
End Sub
 
Private Sub cmdcopybilltoship_Click()
billname = shipname
billaddress = shipaddress
billcity = shipcity
billstate = shipstate
billzip = shipzip
End Sub
 
Private Sub sameasshipping_AfterUpdate()
If Me.sameasshipping Then
Me.billname = Me.shipname
Me.billaddress = Me.shipaddress
Me.billcity = Me.shipcity
Me.billstate = Me.shipstate
Me.billzip = Me.shipzip
End Sub
error messgae: complie error: block if without end if
 
Private Sub sameasshipping_AfterUpdate()
If Me.sameasshipping Then
Me.billname = Me.shipname
Me.billaddress = Me.shipaddress
Me.billcity = Me.shipcity
Me.billstate = Me.shipstate
Me.billzip = Me.shipzip
End Sub
error message: compile error: espected end sub.
 
Private Sub sameasshipping_AfterUpdate()
If Me.sameasshipping Then
Me.billname = Me.shipname
Me.billaddress = Me.shipaddress
Me.billcity = Me.shipcity
Me.billstate = Me.shipstate
Me.billzip = Me.shipzip
End Sub

error message" complie error: block if without end if "
 
Carol said:
Private Sub sameasshipping_AfterUpdate()
If Me.sameasshipping Then
Me.billname = Me.shipname
Me.billaddress = Me.shipaddress
Me.billcity = Me.shipcity
Me.billstate = Me.shipstate
Me.billzip = Me.shipzip
End Sub

error message" complie error: block if without end if "

Your first line has an "If" and you have no corresponding "End If". You need to
add one right before "End Sub".
 
Carol,
Then you have some other problem not related to the code that copies data from one
field to the other. If the situation is as you say, and you followed the instructions
responders submitted, it should work.

If you want, you can send me the database as long as it's not to large. Zip it, and
send it through Contact Me on my website below.
In the email, please describe exactly what form is experiencing the problem.

Also, post a message in this thread, that you sent it. I have some pretty aggresive
spam software.

(No charge of course)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top