L
Lionel Fridjhon
I have a table tblInventory with 4 fields and I need to
extract 12 records into a temporary table that a report
has as a record source.
I have written the following code - the query is created
but comes up empty and the new table "tblTwoPages" is not
created:
========================================
Private Sub cmdRunReport1_Click()
Dim Response As Integer
Dim qdf As AccessObject
'delete old query and table , if they exist
On Error Resume Next
DoCmd.DeleteObject acQuery, "qryTwoPages"
DoCmd.DeleteObject acTable, "tblTwoPages"
'create query
Set qdf = CurrentDb.CreateQueryDef
("qryTwoPages")
qdf.SQL = "SELECT [tblInventory1].#, [
tblInventory1].Location, " _
& "[tblInventory1].Description, [tblInventory1].FileName"
_
& "INTO tblTwoPages " _
& "FROM [tblInventory1] " _
& "WHERE [tblInventory1].#
Between 1 And 12"
qdf.Execute
qdf.Close
DoCmd.OpenReport ("rptInventory1"),
acViewDesign
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, "rptInventory1"
End Sub
===============================================
What am I doing wrong?
Lionel
extract 12 records into a temporary table that a report
has as a record source.
I have written the following code - the query is created
but comes up empty and the new table "tblTwoPages" is not
created:
========================================
Private Sub cmdRunReport1_Click()
Dim Response As Integer
Dim qdf As AccessObject
'delete old query and table , if they exist
On Error Resume Next
DoCmd.DeleteObject acQuery, "qryTwoPages"
DoCmd.DeleteObject acTable, "tblTwoPages"
'create query
Set qdf = CurrentDb.CreateQueryDef
("qryTwoPages")
qdf.SQL = "SELECT [tblInventory1].#, [
tblInventory1].Location, " _
& "[tblInventory1].Description, [tblInventory1].FileName"
_
& "INTO tblTwoPages " _
& "FROM [tblInventory1] " _
& "WHERE [tblInventory1].#
Between 1 And 12"
qdf.Execute
qdf.Close
DoCmd.OpenReport ("rptInventory1"),
acViewDesign
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, "rptInventory1"
End Sub
===============================================
What am I doing wrong?
Lionel