Click to See Complete Forum and Search --> : MS Data Report with User defined Search Criteria


hansel
January 2nd, 2000, 09:57 PM
Basically, I was able to pass the variable (a string) to the parameter and do the query (using a SQL script). However, when I try to do another query I get a message stating that the operation cannot be completed when the object is open.

I then insert code to try to close the object, but then when the window for the data report pops up, it gives a message stating that the operation cannot continue because the object is closed.

I used a simple SQL script defined in the data environment properties dialog..like:

SELECT field1, field2, field3 FROM table1 WHERE (field3=?)

I then placed a button named cmdReport and a text box named txtCountry on the startup form. When the user clicks the command button the country name (previously entered) will be passed as a variable to the parameter defined in the data environment/command properties dialog.

The code works on the first try, however, if I decided to enter another country name (or the same name) and press the command button I get the error messages indicated earlier.

the code sample is:


private Sub cmdReport_Click()
If IsNumeric(txtCountry.Text) = false then
' Insert code to open connection
denvNWind.qryGetCustomerList txtCountry.Text
DataReport2.Show
' Inserted code to close connection
else
MsgBox "Please Enter a Valid string"
End If
End Sub




I would appreciate any suggestions or help.

Sincerely,
Hansel
hansel@solutions2000.net