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.

Figure A

To create the button, follow these steps:

  1. Open the Form in Design Mode.
  2. Click the Command Button control and click and drag where you want to locate the button in your form.
  3. Click Cancel to cancel the Command wizard.
  4. Right-click the Command button and click Properties.
  5. Under the All tab, click in the Caption property box and enter Send Shipping Confirmation.
  6. 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:
Dim MessText

        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

        DoCmd.SendObject _

            ObjectType:=acSendNoObject, _

            To:=Me.ShipEmail, _

            Subject:="Order Confirmation", _

            MessageText:=MessText, _

  1. Press Alt + Q.

Figure B

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.

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.