error 2495

D

David

What would cause this error after executing a sub from a funtion?

Run-time error '2495':

The action or method requires a Table Name argument
***********

The sub runs fine by itself.

=====================================================
Function GetReleases()
NewKits
End Function

Thanks,
David
 
K

Ken Snell

Just a guess, but probably an action or method that is being called/used in
the sub requires a Table Name argument.

Seriously, can you provide a bit more info? What is the code in the NewKits
subroutine?
 
D

David

Sorry, here's the code for the sub:

++++++++++++++++++++++++++++++++++=
Sub NewKits()
Dim RelNum

DoCmd.SetWarnings False
DoCmd.RunMacro "mroNewReleaseFinal"
DoCmd.OpenTable "tblNewReleasesFinal"


RelNum = DCount("*", "tblNewReleasesFinal")

If RelNum = 0 Then

DoCmd.Close acTable, "tblNewReleasesFinal"


MsgBox "No new releases for report run at " & Now(), vbOKOnly
DoCmd.SetWarnings True

Else


RunCommand (acCmdSelectAllRecords)
RunCommand (acCmdCopy)
DoCmd.OpenTable "Released Kits"
RunCommand (acCmdPasteAppend)
DoCmd.Close acTable, "Released Kits"
DoCmd.Close acTable, "tblNewReleasesFinal"


DoCmd.SendObject acSendTable, objectname:="tblNewReleasesFinal",
to:="xxxxxx", cc:="yyyyy", subject:="New Releases", _
messagetext:="yyyyy, add any Safedisc or DVD releases to appropriate tab in
GPS." _
, outputformat:="HTML", editmessage:=False

DoCmd.SendObject acSendTable, objectname:="tblNewKitsWithPrintComp",
to:="xxxxx", cc:="yyyyy", subject:="New Releases with Print Components", _
messagetext:="xxxxx, please download and store these new kits." _
, outputformat:="HTML", editmessage:=False

DoCmd.SetWarnings True
End If

End Sub
+++++++++++++++++++++++++++++
I really appreciate your help, this is really annoying me...

Thanks,
David
 
K

Ken Snell

Guessing here, but is "tblNewKitsWithPrintComp" in the last SendObject step
the correct name of the table in the database?

Side note: Any particular reason you are not using an append query to copy
the data from the first table to the second, instead of opening the tables
and using RunCommand actions? Such as this (this assumes that the field
names are the same in both tables and are in the same order):

Dim dbs As DAO.Database
Dim strSQL As String
Set dbs = CurrentDb
DoCmd.RunMacro "mroNewReleaseFinal"
If DCount("*", "tblNewReleasesFinal") > 0 Then
strSQL = "INSERT INTO [Released Kits] " & _
"SELECT A.* FROM tblNewReleasesFinal " & _
"AS A;"
dbs.Execute strSQL, dbFailOnError
Else
MsgBox "No new releases for report run at " & Now(), vbOKOnly
End If
dbs.Close
Set dbs = Nothing
' continue with your Send Object code
' ......
 
D

David

Thanks so much, Ken. I replaced my code with yours, and it worked great. I
also just put all the code under the _click sub instead of having the click
call a function which called the sub with my code, and that eliminated the
error message at the end (still don't know why it did that, table names were
all good). Plus, I've been wanting to figure out how to use SQL statements
like yours in Access/Excel code, since I use SQL for all my personal
queries, so now I've got a start.

Thanks!
David

Ken Snell said:
Guessing here, but is "tblNewKitsWithPrintComp" in the last SendObject step
the correct name of the table in the database?

Side note: Any particular reason you are not using an append query to copy
the data from the first table to the second, instead of opening the tables
and using RunCommand actions? Such as this (this assumes that the field
names are the same in both tables and are in the same order):

Dim dbs As DAO.Database
Dim strSQL As String
Set dbs = CurrentDb
DoCmd.RunMacro "mroNewReleaseFinal"
If DCount("*", "tblNewReleasesFinal") > 0 Then
strSQL = "INSERT INTO [Released Kits] " & _
"SELECT A.* FROM tblNewReleasesFinal " & _
"AS A;"
dbs.Execute strSQL, dbFailOnError
Else
MsgBox "No new releases for report run at " & Now(), vbOKOnly
End If
dbs.Close
Set dbs = Nothing
' continue with your Send Object code
' ......

--
Ken Snell
<MS ACCESS MVP>




David said:
Sorry, here's the code for the sub:

++++++++++++++++++++++++++++++++++=
Sub NewKits()
Dim RelNum

DoCmd.SetWarnings False
DoCmd.RunMacro "mroNewReleaseFinal"
DoCmd.OpenTable "tblNewReleasesFinal"


RelNum = DCount("*", "tblNewReleasesFinal")

If RelNum = 0 Then

DoCmd.Close acTable, "tblNewReleasesFinal"


MsgBox "No new releases for report run at " & Now(), vbOKOnly
DoCmd.SetWarnings True

Else


RunCommand (acCmdSelectAllRecords)
RunCommand (acCmdCopy)
DoCmd.OpenTable "Released Kits"
RunCommand (acCmdPasteAppend)
DoCmd.Close acTable, "Released Kits"
DoCmd.Close acTable, "tblNewReleasesFinal"


DoCmd.SendObject acSendTable, objectname:="tblNewReleasesFinal",
to:="xxxxxx", cc:="yyyyy", subject:="New Releases", _
messagetext:="yyyyy, add any Safedisc or DVD releases to appropriate tab in
GPS." _
, outputformat:="HTML", editmessage:=False

DoCmd.SendObject acSendTable, objectname:="tblNewKitsWithPrintComp",
to:="xxxxx", cc:="yyyyy", subject:="New Releases with Print Components", _
messagetext:="xxxxx, please download and store these new kits." _
, outputformat:="HTML", editmessage:=False

DoCmd.SetWarnings True
End If

End Sub
+++++++++++++++++++++++++++++
I really appreciate your help, this is really annoying me...

Thanks,
David
called/used
in
 

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

Top