Here's what I've done:
created command1 in dataenvironment. in the sql statement box i wrote:
Code:
select * from routes where ID =?
then in my print command button:
Code:
Dim X As Integer
X = Text1.Text
If (DataEnvironment1.rsCommand1.State = 1) Then
        DataEnvironment1.rsCommand1.Close
    Else
        DataEnvironment1.Command1 (X)
        
        Load DataReport1
        DataReport1.Show
    End If
this works fine since the only parameter will be the ID #. However, I have another print button which prints all the filtered results being shown in my grid. Here are the codes in command2:
Code:
select * from routes where ?
as you can see, instead of a fix "field", I used the parameter right after the where command.
In my "print all" button:
Code:
Dim selectedcat As String
Dim X As String
Dim choice As String
selectedcat = combobox1.text 'this is a dropdown that includes my fields ID, sender, receiver, date, time, etc.
choice = txtchoice.Text 'this is a textbox that receives the key search. Example John Smith as sender
X = selectedcat & " like " & choice
If (DataEnvironment1.rsCommand2.State = 1) Then
        DataEnvironment1.rsCommand2.Close
    Else
        DataEnvironment1.Command2 (X)
        Load DataReport2
        DataReport2.Show
End If
The value of X will therefore be "sender like John Smith" which will be passed to the ? parameter of data report. The problem is, this prints out all the record instead of the desired filter. Any ideas? Thanks