For better customer service, you decide you'd like to send an e-mail message informing customers when their orders have been shipped. However, you don't want to have your shipping personnel spend time composing those messages. Good news: They don't have to! You've already created a form that your staff uses to enter the Ship Date after an item has been shipped. Just add a Command button, like the one in Figure A, to send a shipping confirmation to the customer's e-mail address automatically.
To create the button, follow these steps:
- Open the Form in Design Mode.
- Click the Command Button control and click and drag where you want to locate the button in your form.
- Click Cancel to cancel the Command wizard.
- Right-click the Command button and click Properties.
- Under the All tab, click in the Caption property box and enter Send Shipping Confirmation.
- Under the Event tab, click in the OnClick property box and then click the Build button and enter the following code at the prompt, as shown in Figure B:
MessText = "Your order has shipped!" & vbCrLf & _
"Order Number:" & " " & Me.OrderID & " " & _
"Order Date:" & " " & Me.OrderDate & vbCrLf & _
"Shipped to:" & vbCrLf & _
Me.ShipName & vbCrLf & _
Me.ShipAddress & vbCrLf & _
Me.ShipCity & ", " & Me.ShipStateOrProvince & " " & Me.ShipPostalCode
Subject:="Order Confirmation", _
- Press Alt + Q.
Now, when the user enters the ship date and clicks the Send Shipping Confirmation button, Access will compose the e-mail shown in Figure C.
The user can review the e-mail and click the Send button. Access will then send the e-mail to the address in the ShipEmail field for that order.
Miss an Access tip?
Check out the Microsoft Access archive and catch up on other Access tips.
Help users increase productivity by automatically signing up for TechRepublic's free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.