My code is this.

Dim strSQL As String, strSQL2 As String
Dim db As Connection, rst As ADODB.Recordset
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\River Syde RMS\RiverSyde.mdb;"

strSQL = "SHAPE {SELECT * FROM Sales where Date1=#" & DTPicker3.Value & "#"
    Set rst = New ADODB.Recordset
If rst.State = adStateOpen Then
        rst.Close
    End If

    'db.Open
    rst.CursorLocation = adUseClient
    rst.LockType = adLockOptimistic
    rst.CursorLocation = adUseClient
    rst.CursorType = adOpenStatic

If rst.State = adStateOpen Then rst.Close


rst.Open strSQL, db, adOpenStatic, adLockOptimistic
Set DataReport1.DataSource = rst

With DataReport1.Sections("section1").Controls  ' Group header section
    .Item("Text1").DataField = "PayMode"
End With

With DataReport1.Sections("section1").Controls  ' Detail section
    .Item("text2").DataField = "Last Name"
End With

DataReport1.Show

The error says you are not allowed to start your query with SHAPE. While I do understand this is a valid DMX construct (DMX has been deprecated), the problem may lie in your ODBC connection. Check if it supports DMX.

commented: How do you check DMX and how can I make the program to support it. Thanks +0

I do not know unfortunately, I've never tried to use it. Try searching for an ODBC driver that supports it.

Many are discovering(?) that Visual Basic 6 support is non-existent. If that wasn't bad enough you are pushing the limits of the ODBC with what looks like a deprecated feature.
My advice is to forget VB6 and move on to something current. I know our office did so a few years ago. We had to as the cost to maintain the old VB6 apps climbed and clients weren't able to pay for the higher fees to add the features the clients were asking for. The apps do run, but adding new features is too expensive.

I don’t know VB at all but why do you have SHAPE { with an opening bracket but no closing } anywhere?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.