To order Alpha Four or Alpha Five, click above to go directly to Alpha, or call 800.451.1018 or 781.229.4500
|
|
|
|
|
|
Sunday, December 1, 2002
|
|
VOLUME 1
ISSUE 10
|
|
Bill Warner: Compuniq@aol.com
Jim Chapman: jec@iowatelecom.net
|
|
|  |
 |
 |
Alpha Five Version 5 versus Access
by Tom Mills and John Hertzler
Untitled
We are going to present this article is a different format. John Hertzler and Tom Mills have teamed up to show the difference between using Alpha Five version 5 and Access for the task of displaying multiple selection list box to a user. The selections by the user will then be used to batch print mailing labels. Clicking the link below will take you to a demonstration of how this is done with Alpha Five version. Following that is a description of how this functionality is achieved in Access.
Click here
to view John Hertzler's demonstration of the 'Alpha Five Way'.
Tom Mills describes how he achieves this functionality using Microsoft Access:
We want to produce mailing labels for events. When we do, it usually consists of:
Combine X Y and Z lists and make sure there are no dupes.
So we make a combo box with the data source equal to a query:

If we weren't combining lists we could do this in macros. But since we want to combine lists, we have to go to code, and each version of the report duplicates the code.
Here is the code for one report:
Private Sub print5160_Click()
On Error GoTo Err_print5160_Click
Dim db As DAO.Database
Dim loqd As DAO.QueryDef
Dim vItm As Variant
Dim stWhat As String
Dim stCriteria As String
Dim stSQL As String
Dim counter As Integer
stWhat = "": stCriteria = ",": counter = 0
For Each vItm In Me.CatSelectCombo.ItemsSelected
counter = counter + 1
stWhat = stWhat & "'" & Me!CatSelectCombo.ItemData(vItm) & "'"
stWhat = stWhat & stCriteria
Next vItm
If counter = 0 Then
MsgBox "You did not select a choice from the listbox!"
Exit Sub
End If
Me!txtCriteria = CStr(Left$(stWhat, Len(stWhat) - Len(stCriteria)))
stSQL = "SELECT DISTINCT Main.Envelope1, Main.Envelope2, Main.EnvelopeTitle, Main.Envelope3, Main.Envelope4, "
stSQL = stSQL & "Main.Envelope5, Main.[First Name], Main.[Middle Initial], Main.Envelope6,"
stSQL = stSQL & "Main.[Last Name], Main.[Company Name], Main.Address, Main.Suite, Main.City, "
stSQL = stSQL & "Main.State, Main.[Zip Code] FROM Main INNER JOIN Categories ON Main.ID = Categories.ID "
stSQL = stSQL & "WHERE Categories.Category IN (" & Me!txtCriteria & ");"
Set db = CurrentDb
Set loqd = db.QueryDefs("LabelQuery")
With loqd
.SQL = stSQL
.Close
End With
Set loqd = Nothing
Set db = Nothing
'Opens label report to print labels, then closes form
DoCmd.OpenReport "Labels 5160", acPreview, "", ""
DoCmd.Close acForm, "CatSelector"
Exit_print5160_Click:
Exit Sub
Err_print5160_Click:
MsgBox Err.Description
Resume Exit_print5160_Click
End Sub
Need we say more?
[PRINTER FRIENDLY VERSION]
|
|
| |