coding issues

L

lilbit27

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
 
C

Carl Rapson

My recommendation is to copy the SELECT statement and paste it into a blank
query open in SQL view, and see if you can get it to run there (the error
messages are a little more helpful). Once it's working there, you can paste
it back into your VBA code.

Carl Rapson
 
L

lilbit27

My recommendation is to copy the SELECT statement and paste it into a blank
query open in SQL view, and see if you can get it to run there (the error
messages are a little more helpful). Once it's working there, you can paste
it back into your VBA code.

Carl Rapson




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- Hide quoted text -

- Show quoted text

I have the select stament working, but I can't get my fax code to
work.


Private Sub cmdSendFax_Click()
Dim rst As DAO.Recordset
Dim rsPastDues As DAO.Recordset
Dim db As DAO.Database
Dim strName As String
Dim strFaxNo As String
Dim strFax As String

Set db = CurrentDb


strSQL = "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, " & _
" TP.Zip, QF.TranType, TP.[Contact Name], TP.[Phone Number], TP.[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]<>'----------', QFaxes.[Policy], ' ') AS [Ref#] " & _
" FROM qfaxes AS QF INNER JOIN " & _
" TProdInfo AS TP ON QFaxes.ProdCd = TP.ProdCd " & _
" WHERE (QFaxes.Keep=True)"
If IsNull([contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & [contact name]
End If
strFaxNo = "/Fax=" & [fax number]
strFax = strName & strFaxNo & "/<[email protected]>"

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

End Sub
 
G

Guest

The immediate IIF() is a VBA (VB) function. When you include it in an SQL
string, you have to concatenate the *result* of the IIF(). SQL doesn't know
what to do when it encounters the IIF().

Also it is *really* hard to read the SQL statement like you have it. Try this:



strSQL = "SELECT QFaxes.LogInID, QFaxes.OPID,"
strSQL = strSQL & " QFaxes.AsrName, QFaxes.Acct,"
strSQL = strSQL & " QFaxes.Rpt, QFaxes.BillEffDte,"
strSQL = strSQL & " QFaxes.PolEffDt, QFaxes.Policy,"
strSQL = strSQL & " QFaxes.InsName, QFaxes.ProdCd,"
strSQL = strSQL & " QFaxes.ProdName, QFaxes.State, QFaxes.City,"
strSQL = strSQL & " TP.Zip, QF.TranType, TP.[Contact Name],"
strSQL = strSQL & " TP.[Phone Number], TP.[Fax Number],"
strSQL = strSQL & " QFaxes.Gross, QFaxes.Comm, QFaxes.Net,"
strSQL = strSQL & " QFaxes.Ext, QFaxes.Keep, QFaxes.RptDt,"

'select the return phone number
Select Case [team]
Case "AON", "Marsh", "Swett", "Western", "Willis"
strSQL = strSQL & " (866) 594-4360"
Else
strSQL = strSQL & " (866) 594-4361"
End Select
strSQL = strSQL & " AS ReturnToll,"

'select return fax number
Select Case [team]
Case "AON", "Marsh", "Swett", "Western", "Willis"
strSQL = strSQL & " (877) 867-9495"
Else
strSQL = strSQL & " (800) 842-9569"
End Select
strSQL = strSQL & " AS ReturnFax"

If [SPCPol] <> "----------" Then
strSQL = strSQL & " QFaxes.[Policy]"
Else
strSQL = strSQL & " "
End If
strSQL = strSQL & " AS [Ref#]"


strSQL = strSQL & " FROM qfaxes AS QF INNER JOIN"
strSQL = strSQL & " TProdInfo AS TP ON QFaxes.ProdCd = TP.ProdCd"
strSQL = strSQL & " WHERE (QFaxes.Keep=True)"

If IsNull([contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & [contact name]
End If
strFaxNo = "/Fax=" & [fax number]
strFax = strName & strFaxNo & "/<[email protected]>"

'-------------------------------
'for debugging. view output in the immediate window
' press ctl-G to open window
'delete or comment out after debugging complete
Debug.Print strSQL
'-------------------------------

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


Set a breakpoint on the "Docmd" statement and look at the SQL in the
immediate window (open it by typing <ctl-G>).

Is the SQL what you expect??


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


lilbit27 said:
My recommendation is to copy the SELECT statement and paste it into a blank
query open in SQL view, and see if you can get it to run there (the error
messages are a little more helpful). Once it's working there, you can paste
it back into your VBA code.

Carl Rapson




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- Hide quoted text -

- Show quoted text

I have the select stament working, but I can't get my fax code to
work.


Private Sub cmdSendFax_Click()
Dim rst As DAO.Recordset
Dim rsPastDues As DAO.Recordset
Dim db As DAO.Database
Dim strName As String
Dim strFaxNo As String
Dim strFax As String

Set db = CurrentDb


strSQL = "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, " & _
" TP.Zip, QF.TranType, TP.[Contact Name], TP.[Phone Number], TP.[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]<>'----------', QFaxes.[Policy], ' ') AS [Ref#] " & _
" FROM qfaxes AS QF INNER JOIN " & _
" TProdInfo AS TP ON QFaxes.ProdCd = TP.ProdCd " & _
" WHERE (QFaxes.Keep=True)"
If IsNull([contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & [contact name]
End If
strFaxNo = "/Fax=" & [fax number]
strFax = strName & strFaxNo & "/<[email protected]>"

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

End Sub
 
L

lilbit27

The immediate IIF() is a VBA (VB) function. When you include it in an SQL
string, you have to concatenate the *result* of the IIF(). SQL doesn't know
what to do when it encounters the IIF().

Also it is *really* hard to read the SQL statement like you have it. Try this:

strSQL = "SELECT QFaxes.LogInID, QFaxes.OPID,"
strSQL = strSQL & " QFaxes.AsrName, QFaxes.Acct,"
strSQL = strSQL & " QFaxes.Rpt, QFaxes.BillEffDte,"
strSQL = strSQL & " QFaxes.PolEffDt, QFaxes.Policy,"
strSQL = strSQL & " QFaxes.InsName, QFaxes.ProdCd,"
strSQL = strSQL & " QFaxes.ProdName, QFaxes.State, QFaxes.City,"
strSQL = strSQL & " TP.Zip, QF.TranType, TP.[Contact Name],"
strSQL = strSQL & " TP.[Phone Number], TP.[Fax Number],"
strSQL = strSQL & " QFaxes.Gross, QFaxes.Comm, QFaxes.Net,"
strSQL = strSQL & " QFaxes.Ext, QFaxes.Keep, QFaxes.RptDt,"

'select the return phone number
Select Case [team]
Case "AON", "Marsh", "Swett", "Western", "Willis"
strSQL = strSQL & " (866) 594-4360"
Else
strSQL = strSQL & " (866) 594-4361"
End Select
strSQL = strSQL & " AS ReturnToll,"

'select return fax number
Select Case [team]
Case "AON", "Marsh", "Swett", "Western", "Willis"
strSQL = strSQL & " (877) 867-9495"
Else
strSQL = strSQL & " (800) 842-9569"
End Select
strSQL = strSQL & " AS ReturnFax"

If [SPCPol] <> "----------" Then
strSQL = strSQL & " QFaxes.[Policy]"
Else
strSQL = strSQL & " "
End If
strSQL = strSQL & " AS [Ref#]"

strSQL = strSQL & " FROM qfaxes AS QF INNER JOIN"
strSQL = strSQL & " TProdInfo AS TP ON QFaxes.ProdCd = TP.ProdCd"
strSQL = strSQL & " WHERE (QFaxes.Keep=True)"

If IsNull([contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & [contact name]
End If
strFaxNo = "/Fax=" & [fax number]
strFax = strName & strFaxNo & "/<[email protected]>"

'-------------------------------
'for debugging. view output in the immediate window
' press ctl-G to open window
'delete or comment out after debugging complete
Debug.Print strSQL
'-------------------------------

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

Set a breakpoint on the "Docmd" statement and look at the SQL in the
immediate window (open it by typing <ctl-G>).

Is the SQL what you expect??

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)



lilbit27 said:
My recommendation is to copy the SELECT statement and paste it into a blank
query open in SQL view, and see if you can get it to run there (the error
messages are a little more helpful). Once it's working there, you can paste
it back into your VBA code.
Carl Rapson

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- Hide quoted text -
- Show quoted text
I have the select stament working, but I can't get my fax code to
work.
Private Sub cmdSendFax_Click()
Dim rst As DAO.Recordset
Dim rsPastDues As DAO.Recordset
Dim db As DAO.Database
Dim strName As String
Dim strFaxNo As String
Dim strFax As String
Set db = CurrentDb
strSQL = "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, " & _
" TP.Zip, QF.TranType, TP.[Contact Name], TP.[Phone Number], TP.[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]<>'----------', QFaxes.[Policy], ' ') AS [Ref#] " & _
" FROM qfaxes AS QF INNER JOIN " & _
" TProdInfo AS TP ON QFaxes.ProdCd = TP.ProdCd " & _
" WHERE (QFaxes.Keep=True)"
If IsNull([contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & [contact name]
End If
strFaxNo = "/Fax=" & [fax number]
strFax = strName & strFaxNo & "/<[email protected]>"
DoCmd.SendObject acSendReport, "RPCDemandFax", acFormatRTF,
strFax, , , "Outstanding Property Casualty Policies", "Please Review
the Following Outstanding Policies", False
End Sub- Hide quoted text -

- Show quoted text -

yes,

now what if there were more than one report with different fax
numbers, how would i loop through and send the report to each fax
number
 
L

lilbit27

The immediate IIF() is a VBA (VB) function. When you include it in an SQL
string, you have to concatenate the *result* of the IIF(). SQL doesn't know
what to do when it encounters the IIF().

Also it is *really* hard to read the SQL statement like you have it. Try this:

strSQL = "SELECT QFaxes.LogInID, QFaxes.OPID,"
strSQL = strSQL & " QFaxes.AsrName, QFaxes.Acct,"
strSQL = strSQL & " QFaxes.Rpt, QFaxes.BillEffDte,"
strSQL = strSQL & " QFaxes.PolEffDt, QFaxes.Policy,"
strSQL = strSQL & " QFaxes.InsName, QFaxes.ProdCd,"
strSQL = strSQL & " QFaxes.ProdName, QFaxes.State, QFaxes.City,"
strSQL = strSQL & " TP.Zip, QF.TranType, TP.[Contact Name],"
strSQL = strSQL & " TP.[Phone Number], TP.[Fax Number],"
strSQL = strSQL & " QFaxes.Gross, QFaxes.Comm, QFaxes.Net,"
strSQL = strSQL & " QFaxes.Ext, QFaxes.Keep, QFaxes.RptDt,"

'select the return phone number
Select Case [team]
Case "AON", "Marsh", "Swett", "Western", "Willis"
strSQL = strSQL & " (866) 594-4360"
Else
strSQL = strSQL & " (866) 594-4361"
End Select
strSQL = strSQL & " AS ReturnToll,"

'select return fax number
Select Case [team]
Case "AON", "Marsh", "Swett", "Western", "Willis"
strSQL = strSQL & " (877) 867-9495"
Else
strSQL = strSQL & " (800) 842-9569"
End Select
strSQL = strSQL & " AS ReturnFax"

If [SPCPol] <> "----------" Then
strSQL = strSQL & " QFaxes.[Policy]"
Else
strSQL = strSQL & " "
End If
strSQL = strSQL & " AS [Ref#]"

strSQL = strSQL & " FROM qfaxes AS QF INNER JOIN"
strSQL = strSQL & " TProdInfo AS TP ON QFaxes.ProdCd = TP.ProdCd"
strSQL = strSQL & " WHERE (QFaxes.Keep=True)"

If IsNull([contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & [contact name]
End If
strFaxNo = "/Fax=" & [fax number]
strFax = strName & strFaxNo & "/<[email protected]>"

'-------------------------------
'for debugging. view output in the immediate window
' press ctl-G to open window
'delete or comment out after debugging complete
Debug.Print strSQL
'-------------------------------

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

Set a breakpoint on the "Docmd" statement and look at the SQL in the
immediate window (open it by typing <ctl-G>).

Is the SQL what you expect??

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)



lilbit27 said:
My recommendation is to copy the SELECT statement and paste it into a blank
query open in SQL view, and see if you can get it to run there (the error
messages are a little more helpful). Once it's working there, you can paste
it back into your VBA code.
Carl Rapson

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- Hide quoted text -
- Show quoted text
I have the select stament working, but I can't get my fax code to
work.
Private Sub cmdSendFax_Click()
Dim rst As DAO.Recordset
Dim rsPastDues As DAO.Recordset
Dim db As DAO.Database
Dim strName As String
Dim strFaxNo As String
Dim strFax As String
Set db = CurrentDb
strSQL = "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, " & _
" TP.Zip, QF.TranType, TP.[Contact Name], TP.[Phone Number], TP.[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]<>'----------', QFaxes.[Policy], ' ') AS [Ref#] " & _
" FROM qfaxes AS QF INNER JOIN " & _
" TProdInfo AS TP ON QFaxes.ProdCd = TP.ProdCd " & _
" WHERE (QFaxes.Keep=True)"
If IsNull([contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & [contact name]
End If
strFaxNo = "/Fax=" & [fax number]
strFax = strName & strFaxNo & "/<[email protected]>"
DoCmd.SendObject acSendReport, "RPCDemandFax", acFormatRTF,
strFax, , , "Outstanding Property Casualty Policies", "Please Review
the Following Outstanding Policies", False
End Sub- Hide quoted text -

- Show quoted text -

how di I reference the [contact name] in the following statement:
If IsNull([contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & [contact name]
End If
strFaxNo = "/Fax=" & [fax number]
strFax = strName & strFaxNo & "/<[email protected]>"


when the contact name is on the tp table and not the on the the same
recordset of the form where i have the command button that is running
this code.
 
G

Guest

how di I reference the [contact name] in the following statement:
If IsNull([contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & [contact name]
End If
strFaxNo = "/Fax=" & [fax number]
strFax = strName & strFaxNo & "/<[email protected]>"


when the contact name is on the tp table and not the on the the same
recordset of the form where i have the command button that is running
this code.

I'm not sure I understand the question in the last two posts, but try the
following code. I would set a breakpoint and trace the code (remembering that
this is AIR CODE)

(and watch for line wrap)

'--------------------------------------------------------
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

strSQL = "SELECT QFaxes.LogInID, QFaxes.OPID,"
strSQL = strSQL & " QFaxes.AsrName, QFaxes.Acct,"
strSQL = strSQL & " QFaxes.Rpt, QFaxes.BillEffDte,"
strSQL = strSQL & " QFaxes.PolEffDt, QFaxes.Policy,"
strSQL = strSQL & " QFaxes.InsName, QFaxes.ProdCd,"
strSQL = strSQL & " QFaxes.ProdName, QFaxes.State, QFaxes.City,"
strSQL = strSQL & " TP.Zip, QF.TranType, TP.[Contact Name],"
strSQL = strSQL & " TP.[Phone Number], TP.[Fax Number],"
strSQL = strSQL & " QFaxes.Gross, QFaxes.Comm, QFaxes.Net,"
strSQL = strSQL & " QFaxes.Ext, QFaxes.Keep, QFaxes.RptDt,"

'select the return phone number
Select Case [team]
Case "AON", "Marsh", "Swett", "Western", "Willis"
strSQL = strSQL & " (866) 594-4360"
Else
strSQL = strSQL & " (866) 594-4361"
End Select
strSQL = strSQL & " AS ReturnToll,"

'select return fax number
Select Case [team]
Case "AON", "Marsh", "Swett", "Western", "Willis"
strSQL = strSQL & " (877) 867-9495"
Else
strSQL = strSQL & " (800) 842-9569"
End Select
strSQL = strSQL & " AS ReturnFax"

If [SPCPol] <> "----------" Then
strSQL = strSQL & " QFaxes.[Policy]"
Else
strSQL = strSQL & " "
End If
strSQL = strSQL & " AS [Ref#]"


strSQL = strSQL & " FROM qfaxes AS QF INNER JOIN"
strSQL = strSQL & " TProdInfo AS TP ON QFaxes.ProdCd = TP.ProdCd"
strSQL = strSQL & " WHERE (QFaxes.Keep=True)"

'open the recordset
Set rsfax = db.OpenRecordset(strSQL)

With rsfax
' check for records
If Not (.BOF And .EOF) Then
'loop thru records
.MoveFirst
Do While Not .EOF
If IsNull(![contact name]) Then
strName = "/Name=Accounting.Dept"
Else
strName = "/Name=" & ![contact name]
End If
strFaxNo = "/Fax=" & ![fax number]
strFax = !strName & !strFaxNo & "/<[email protected]>"

'-------------------------------
'for debugging. view output in the immediate window
' press ctl-G to open window
'delete or comment out after debugging complete
' Debug.Print strSQL
'-------------------------------

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

' go to the next record
.MoveNext
Loop
End If
End With



' don't forget to clean up at some point
' rsfax.Close
' Set rsfax = Nothing
' Set db = Nothing

'--------------------------------------------------------



HTH
 

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

syntax error 1

Top