709-218-7927

The Landfall Garden House

60 Canon Bayley Road

CANADA A0C 1B0

CPRGreaves@gmail.com

Home

Christopher Greaves

Tagging For Email, Fax And Postal Transmission

It will come as no surprise to you that I have another little application in Word that will establish contact with my Access database and extract data for the production and transmission of memos and letters by facsimile, electronic mail, and by the regular postal services.

The Word application depends on a recognizable flag in the table of clients.

I need three Command Buttons, each one capable of setting the appropriate value in the field, and checking that there is no conflict with other data fields.

Here we go.

In all events we will attempt to lodge a flag in a field called "MPCD2", a weird name, but a historic relic. I think of it as "Mailing Postal CoDe number 2". If we want to send a fax we will place the letter "F" in this field, and "E" for an email and "M" for a regular postal letter.

Of course, if there is already a code lodged in there we should warn the user (that's us!), and not overwrite the existing tag.

If we want to send a fax we should check that we do have a telephone number for the client's facsimile machine. If we want to send an email, likewise, we should test that we have an email address. And if we are to mail a letter, at least check that we have a postal code, one line of address and a city.

You know enough now to create three Command Buttons, cmd_Fax, cmd_Email and cmd_Mail, with appropriate captions.

Here is the FAX Click event procedure code:

Private Sub cmd_Fax_Click()
If IsNull(Me.FAX) Then
MsgBox "No fax number!"
Me.FAX.SetFocus
Else
If Me.FAX = "" Then
MsgBox "No fax number!"
Me.FAX.SetFocus
Else
' Set the flag
If IsNull(Me.MPCD2) Or Trim(Me.MPCD2) = "" Then
Me.MPCD2 = "F"
Else
MsgBox "Already sending " & Me.MPCD2
End If
End If
End If
End Sub

If the FAX field is NULL or is an empty string, we will pop up a message box saying so, and we will place the text cursor in the FAX field. If you are still chatting with the client, you can ask for, and immediately type, their facsimile telephone number..

Providing that the MPCD2 flag has not been filled, we will charge it with the letter "F", otherwise we will inform the user.

Here is the EMAIL Click event procedure:

Private Sub cmd_Email_Click()
If IsNull(Me.MAILAD) Then
MsgBox "No email address!"
Me.MAILAD.SetFocus
Else
If Me.MAILAD = "" Then
MsgBox "No email address!"
Me.MAILAD.SetFocus
Else
' Set the flag
If IsNull(Me.MPCD2) Or Trim(Me.MPCD2) = "" Then
Me.MPCD2 = "E"
Else
MsgBox "Already sending " & Me.MPCD2
End If
End If
End If
End Sub

Here is the Postal Mail procedure:

Private Sub cmd_Mail_Click()
If IsNull(Me.POSTCODE) Then
MsgBox "No Postal address!"
Me.POSTCODE.SetFocus
Else
If Me.POSTCODE = "" Then
MsgBox "No Postal address!"
Me.POSTCODE.SetFocus
Else
' Set the flag
If IsNull(Me.MPCD2) Or Trim(Me.MPCD2) = "" Then
Me.MPCD2 = "M"
Else
MsgBox "Already sending " & Me.MPCD2
End If
End If
End If
End Sub

For brevity in this material we have restricted our check to there being a postal code; in your application you might include tests for Address and City data.

7092187927 CPRGreaves@gmail.com

Bonavista, Friday, December 04, 2020 5:51 PM

Copyright © 1996-2020 Chris Greaves. All Rights Reserved.