G
Guest
new to VB the code below keeps returning Compile error need help Pleas
Private Sub cmdCreateList_Click(
Dim Item As Varian
Dim intCounter As Intege
Dim intMaxCount As Intege
Dim strSQL As Strin
Dim frm As For
Dim ctl As Contro
Dim varItm As Varian
Dim strGroup As Strin
Dim strTable As Strin
Application.SetOption "Confirm Action Queries", Fals
'Cleans out the data from the Mailing List tabl
DoCmd.RunSQL "DELETE tblMailingList.* FROM tblMailingList
'Set up counter to select all list
intMaxCount = Me.MailingList.ListCount -
intCounter =
'Goes through list box and gets selected group
Set ctl = Me.MailingLis
For Each varItm In ctl.ItemsSelecte
strGroup = ctl.Column(0, varItm
'Inserts records for each selected group into tblMailingLis
strSQL = "INSERT INTO tblMailingList ( Salutation, FirstName, MiddleName, LastName, Suffix, " &
"Address, City, State, Zip, Company ) " &
"SELECT MainDonorBio.Prefix, MainDonorBio.FirstName, MainDonorBio.MI, MainDonorBio.LastName, " &
"MainDonorBio.Suffix, IIf([PreferredMailingAddress]='P',[HomeAddressLineOne],[HomeAddressLineTwo],[WorkAddressLineOne],[WorkAddressLineTwo]) AS Address, " &
"IIf([PreferredMailingAddress]='P',[HomeCity],[WorkCity]) AS City, " &
"IIf([PreferredMailingAddress]='P',[HomeStateOrProvince],[WorkStateOrProvince]) AS State, " &
"IIf([PreferredMailingAddress]='P',[HomePostalCode],[WorkPostalCode]) AS Zip, " &
"IIf([PreferredMailingAddress]='P',Null,[Organization]) AS Company1 " &
"FROM MainDonorBio INNER JOIN Mailings ON MainDonorBio.DonorID = Mailings.DonorID " &
"WHERE (((Mailings.MailingList)= '" & strGroup & "') AND (MainDonorBio.BadMailingAddressYN)=False)
DoCmd.RunSQL (strSQL
'Cleans out the data from tblMailingListUnique
DoCmd.RunSQL "DELETE tblMailingListUnique.* FROM tblMailingListUnique
'Appends records from tblMailingList to tblMailingListUnique so tha
'duplicates are removed
DoCmd.OpenQuery "qryMailingListAppend
DoCmd.OpenTable "tblMailingListUnique
End Sub
Private Sub cmdCreateList_Click(
Dim Item As Varian
Dim intCounter As Intege
Dim intMaxCount As Intege
Dim strSQL As Strin
Dim frm As For
Dim ctl As Contro
Dim varItm As Varian
Dim strGroup As Strin
Dim strTable As Strin
Application.SetOption "Confirm Action Queries", Fals
'Cleans out the data from the Mailing List tabl
DoCmd.RunSQL "DELETE tblMailingList.* FROM tblMailingList
'Set up counter to select all list
intMaxCount = Me.MailingList.ListCount -
intCounter =
'Goes through list box and gets selected group
Set ctl = Me.MailingLis
For Each varItm In ctl.ItemsSelecte
strGroup = ctl.Column(0, varItm
'Inserts records for each selected group into tblMailingLis
strSQL = "INSERT INTO tblMailingList ( Salutation, FirstName, MiddleName, LastName, Suffix, " &
"Address, City, State, Zip, Company ) " &
"SELECT MainDonorBio.Prefix, MainDonorBio.FirstName, MainDonorBio.MI, MainDonorBio.LastName, " &
"MainDonorBio.Suffix, IIf([PreferredMailingAddress]='P',[HomeAddressLineOne],[HomeAddressLineTwo],[WorkAddressLineOne],[WorkAddressLineTwo]) AS Address, " &
"IIf([PreferredMailingAddress]='P',[HomeCity],[WorkCity]) AS City, " &
"IIf([PreferredMailingAddress]='P',[HomeStateOrProvince],[WorkStateOrProvince]) AS State, " &
"IIf([PreferredMailingAddress]='P',[HomePostalCode],[WorkPostalCode]) AS Zip, " &
"IIf([PreferredMailingAddress]='P',Null,[Organization]) AS Company1 " &
"FROM MainDonorBio INNER JOIN Mailings ON MainDonorBio.DonorID = Mailings.DonorID " &
"WHERE (((Mailings.MailingList)= '" & strGroup & "') AND (MainDonorBio.BadMailingAddressYN)=False)
DoCmd.RunSQL (strSQL
'Cleans out the data from tblMailingListUnique
DoCmd.RunSQL "DELETE tblMailingListUnique.* FROM tblMailingListUnique
'Appends records from tblMailingList to tblMailingListUnique so tha
'duplicates are removed
DoCmd.OpenQuery "qryMailingListAppend
DoCmd.OpenTable "tblMailingListUnique
End Sub