G
Guest
Hi,
I previously had a query that was too complex to be evaluated (apparently).
A nice person on this site told me to construct a 'make table' query.
The results are for a report, so I have made the report have the onopen
event as below:
Private Sub Report_Open(CANCEL As Integer)
Dim self1 As String
If <statement> Then
self1 = "SELECT <variables> INTO <newtable> FROM <table1> INNER JOIN
<table2> ON <table 1 field> = <table 2 field> WHERE <statement 1>;"
Else
self1 = "SELECT <variables> INTO <newtable> FROM <table1> INNER JOIN
<table2> ON <table 1 field> = <table 2 field> WHERE <statement 2>;"
End If
DoCmd.RunSQL self1
With Report
.RecordSource = "SELECT <fields from newtable>
"FROM <newtable>
"WHERE <statement>
"ORDER BY <field> DESC;"
End With
End Sub
It all seems to work except for the DoCmd.RunSQL self1
at which point it just stops and the report is empty. With setwarnings=true
if brings up a warning asking me if it's OK to replace the contents of the
newtable. I click yes, but when Ilook at the contents of newtable they have
not been updated.
Any suggestions?
Thanks in advance for all your help.
I previously had a query that was too complex to be evaluated (apparently).
A nice person on this site told me to construct a 'make table' query.
The results are for a report, so I have made the report have the onopen
event as below:
Private Sub Report_Open(CANCEL As Integer)
Dim self1 As String
If <statement> Then
self1 = "SELECT <variables> INTO <newtable> FROM <table1> INNER JOIN
<table2> ON <table 1 field> = <table 2 field> WHERE <statement 1>;"
Else
self1 = "SELECT <variables> INTO <newtable> FROM <table1> INNER JOIN
<table2> ON <table 1 field> = <table 2 field> WHERE <statement 2>;"
End If
DoCmd.RunSQL self1
With Report
.RecordSource = "SELECT <fields from newtable>
"FROM <newtable>
"WHERE <statement>
"ORDER BY <field> DESC;"
End With
End Sub
It all seems to work except for the DoCmd.RunSQL self1
at which point it just stops and the report is empty. With setwarnings=true
if brings up a warning asking me if it's OK to replace the contents of the
newtable. I click yes, but when Ilook at the contents of newtable they have
not been updated.
Any suggestions?
Thanks in advance for all your help.