syntax error

L

lilbit27

I am trying to start a loop code but I keep getting a syntax error in
my

select statement.:

Dim rsfax As DAO.Recordset
Dim rsPastDues As DAO.Recordset
Dim db As DAO.Database

Set db = CurrentDb
Set rsPastDues =

Forms.FPastDueMainView.FPastDues.Form.RecordsetClone
Set rsFax = db.OpenRecordset("SELECT qfaxes.LogInID, qfaxes.OPID,
qfaxes.AsrName, qfaxes.Acct, qfaxes.Rpt, qfaxes.BillEffDte,
qfaxes.PolEffDt, qfaxes.Policy, qfaxes.InsName, qfaxes.ProdCd,
qfaxes.ProdName, qfaxes.State, qfaxes.City, TProdInfo.Zip,
qfaxes.TranType, TProdInfo.[Contact Name], TProdInfo.[Phone Number],
TProdInfo.[Fax Number], qfaxes.Gross, qfaxes.Comm, qfaxes.Net,
qfaxes.Ext, qfaxes.Keep, qfaxes.RptDt, IIf([Team] In
(""AON"",""Marsh"",""Swett"",""Western"",""Willis""),""(866)
594-4360"",""(866) 594-4361"") AS ReturnToll, IIf([Team] In
(""AON"",""Marsh"",""Swett"",""Western"",""Willis""),""(877)
867-9495"",""(800) 842-9569"") AS ReturnFax,
IIf([SPCPol]<>"----------",[Policy],"") AS [Ref#], qfaxes.Email", _
FROM qfaxes INNER JOIN TProdInfo ON qfaxes.ProdCd = TProdInfo.ProdCd",
_
WHERE (((qfaxes.Keep)=True) AND ((qfaxes.Email)=fOSUserName()))"

DoCmd.SendObject acSendReport, "RPCDemandFax", acFormatRTF,
strFax, , , "Outstanding Property Casualty Policies", "Please Review
the Following Outstanding Policies", False
 
D

Douglas J. Steele

You want the value that's returned by fOSUserName. That means you need to
put it outside of the quotes. (However, since it's a text value, you have to
ensure that the value returned is enclosed in quotes).

Try replacing the Where clause with:

"WHERE (((qfaxes.Keep)=True) AND ((qfaxes.Email)='" & fOSUserName() & "'))"

Exagerated for clarity, that's

"WHERE (((qfaxes.Keep)=True) AND ((qfaxes.Email)= ' " & fOSUserName() & "
' ))"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

coding issues 6

Top