D
DontKnow
Hi Guys,
If I wanted to include the output from a query in an email using the
"sendobject" function I receive an error sqaying thast the query is empty.
(The actual error I receive is: "The Object Type argument for the action or
method is blank or invalid").
Yet when I open the query, it does in fact have records in it.
Here is my cod e for the send object:
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim strsql As String
Dim nextdate As String
Dim emailaddress As String
nextdate = DateAdd("m", 1, Date) ' one month ahead of current date for all
Rego Expiry dates
emailaddress = "(e-mail address removed)"
strsql = "SELECT Rego.RegoID, Rego.RegoNo, Rego.RegoExpiryDate,
Rego.VehicleMake, Rego.VehicleModel " & _
"FROM Rego " & _
"WHERE (((Rego.RegoExpiryDate) Between Date() And #" & nextdate & "#));"
Set dbs = DBEngine(0)(0)
If DCount("Name", "msysobjects", "[Name] = 'qrytemp'") = 0 Then
Set qdf = CurrentDb.CreateQueryDef("qrytemp", strsql)
'DoCmd.OpenQuery "qrytemp"
'Set rst = qdf.OpenRecordset
'rst.MoveFirst
'MsgBox rst.Fields("RegoNo")
DoCmd.SendObject acSendQuery, qrytemp, acSendTable, emailaddress, , , "Sue
You need to update the Rego Expiry dates for the following cars!!", , False
Else
Set qdf = CurrentDb.QueryDefs("qrytemp")
qdf.SQL = strsql
DoCmd.OpenQuery "qrytemp"
MsgBox qrytemp
DoCmd.SendObject acSendQuery, qrytemp, acSendTable, emailaddress, , , "Sue
You need to update the Rego Expiry dates for the following cars!!", , False
'MsgBox rst.Fields("RegoNo")
Set rst = qdf.OpenRecordset
rst.MoveFirst
MsgBox rst.Fields("RegoNo")
End If
Please help me, as I cannot fix the error,
many thanks,
If I wanted to include the output from a query in an email using the
"sendobject" function I receive an error sqaying thast the query is empty.
(The actual error I receive is: "The Object Type argument for the action or
method is blank or invalid").
Yet when I open the query, it does in fact have records in it.
Here is my cod e for the send object:
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim strsql As String
Dim nextdate As String
Dim emailaddress As String
nextdate = DateAdd("m", 1, Date) ' one month ahead of current date for all
Rego Expiry dates
emailaddress = "(e-mail address removed)"
strsql = "SELECT Rego.RegoID, Rego.RegoNo, Rego.RegoExpiryDate,
Rego.VehicleMake, Rego.VehicleModel " & _
"FROM Rego " & _
"WHERE (((Rego.RegoExpiryDate) Between Date() And #" & nextdate & "#));"
Set dbs = DBEngine(0)(0)
If DCount("Name", "msysobjects", "[Name] = 'qrytemp'") = 0 Then
Set qdf = CurrentDb.CreateQueryDef("qrytemp", strsql)
'DoCmd.OpenQuery "qrytemp"
'Set rst = qdf.OpenRecordset
'rst.MoveFirst
'MsgBox rst.Fields("RegoNo")
DoCmd.SendObject acSendQuery, qrytemp, acSendTable, emailaddress, , , "Sue
You need to update the Rego Expiry dates for the following cars!!", , False
Else
Set qdf = CurrentDb.QueryDefs("qrytemp")
qdf.SQL = strsql
DoCmd.OpenQuery "qrytemp"
MsgBox qrytemp
DoCmd.SendObject acSendQuery, qrytemp, acSendTable, emailaddress, , , "Sue
You need to update the Rego Expiry dates for the following cars!!", , False
'MsgBox rst.Fields("RegoNo")
Set rst = qdf.OpenRecordset
rst.MoveFirst
MsgBox rst.Fields("RegoNo")
End If
Please help me, as I cannot fix the error,
many thanks,