> You were on the right track with DROP, here's an example ...
>
[quoted text clipped - 48 lines]
> > Crystal
> > Report that is hard-coded to use a main query.
Joins aren't the problem, Robert. There are other restrictions, though. You
don't seem to be able to use an ORDER BY clause in a view. I tried using
SELECT TOP 100 PERCENT, which I understand is what you have to do to use
ORDER BY in a SQL Server view, but that doesn't seem to work in JET. You can
still use an ORDER BY clause, though, you just have to create a procedure
rather than a view ...
Module Module1
Sub Main()
Dim strCnn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\usenet\db1.mdb;" & _
"Persist Security Info=False;" & _
"Jet OLEDB:Database Password=password"
Dim cnn As New System.Data.OleDb.OleDbConnection(strCnn)
Dim cmd As System.Data.OleDb.OleDbCommand
Try
cnn.Open()
cmd = New System.Data.OleDb.OleDbCommand
cmd.Connection = cnn
cmd.CommandText = "DROP VIEW vTest"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP PROCEDURE pTest"
cmd.ExecuteNonQuery()
cmd.CommandText = _
"CREATE VIEW vTest AS SELECT " & _
"Customers.CustomerID, " & _
"Orders.OrderID FROM Customers INNER JOIN Orders ON " & _
"Customers.CustomerID = Orders.CustomerID"
cmd.ExecuteNonQuery()
Console.WriteLine("View created")
Console.ReadLine()
cmd.CommandText = _
"CREATE PROCEDURE pTest AS SELECT " & _
"Customers.CustomerID, " & _
"Orders.OrderID FROM Customers INNER JOIN Orders ON " & _
"Customers.CustomerID = Orders.CustomerID " & _
"ORDER BY Customers.CustomerID DESC"
cmd.ExecuteNonQuery()
Console.WriteLine("Procedure created")
Console.ReadLine()
Catch ex As Exception
Console.WriteLine(ex.Message)
Console.ReadLine()
Finally
If Not cnn Is Nothing Then
If cnn.State <> ConnectionState.Closed Then
cnn.Close()
End If
End If
End Try
End Sub
End Module

Signature
Brendan Reynolds
Access MVP
> Excellent! That did it! I ended up with a significant discovery - If you
> have joins in your query Access generates an error telling you that it can
[quoted text clipped - 66 lines]
>> > Crystal
>> > Report that is hard-coded to use a main query.
Robert - 18 Jan 2006 06:47 GMT
Brendan, That was one of the most eloquent answers I have had in a long time!
Thank you! While I am aware that I could create a stored proc I did not
choose that way. In Access a stored proc is not easily implemented/used by
Crystal Reports. I wanted to keep my report, my code, and my database simple
and I tried the following instead:
1.) My original query would not recreate exactly as it was (it did have an
Order By clause by the way). It contained multiple joins, some inner some
right.
2.) I knew that something specific about my query may be the cause besides
the joins, but I wanted to back off from testing any tweaks to the query - I
decided to blame it on the joins ... excuses are more fun than the truth
sometimes ...
3.) I decided to "simplify" the query as the error message suggested.
Instead, I inserted a new query that would all the fields from original and
add my filter to it instead.
4.) This worked well and I implemented the idea farther up the tree of
queries that my main query called. I didn't need to change anything besides
add two new queries. My report runs and my filters are working as desired.
Now I need to figure out how to create an installation app that includes all
my files and the crystal report engine as well ... that's for another forum
...
Thank you Brendan, I would love to work along side someone like you someday!
Good luck to you!
> Joins aren't the problem, Robert. There are other restrictions, though. You
> don't seem to be able to use an ORDER BY clause in a view. I tried using
[quoted text clipped - 122 lines]
> >> > Crystal
> >> > Report that is hard-coded to use a main query.
Brendan Reynolds - 18 Jan 2006 10:58 GMT
You're very welcome, Robert, and I'm glad it's working for you. I was just
trying to be accurate - you never know how many other people with similar
problems may be following a thread, or may read it later in the archives.

Signature
Brendan Reynolds
Access MVP
> Brendan, That was one of the most eloquent answers I have had in a long
> time!
[quoted text clipped - 175 lines]
>> >> > Crystal
>> >> > Report that is hard-coded to use a main query.