Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Environment Command Syntax Error VB6 1

Status
Not open for further replies.

nitinsharma

Technical User
Jun 20, 2002
5
US
Hi All,
I have a simple database app which connects to a microsoft access 2.0 database using VB 6.0's data environment designer. I managed to add, delete, even specify a query which selects records with date= certain value. However, when I use the following code to select records within a range of dates i get a syntax error on the line where the command is called from the data environment. I am trying to run this command during run-time - My command is based on a sql query which has the following syntax:
Code:
SELECT `Date`, `Time`, BS, Qty, `Month`, Strike, ProdTyp, Price, ID FROM trades WHERE (`Date` >= startrange) AND (`Date` <= endrange)
this causes the command to take on two parameters, startrange and endrange. it works fine when only one value is specified, i.e.
Code:
SELECT `Date`, `Time`, BS, Qty, `Month`, Strike, ProdTyp, Price, ID FROM trades WHERE (`Date` >= startrange)
works fine with just one parameter input, but when you use a range the IDE itself throws a syntax error (Which says Expected :=) and refuses to compile the code.

Code:
Private Sub optnRange_Click()


If range1 = "" Then
range1 = Text8.Text
range2 = Text9.Text
DataEnvironment1.dtrange(range1,range2) 'ERROR
Else:
DataEnvironment1.rsdtrange.Close
range1 = Text8.Text
range2 = Text9.Text
DataEnvironment1.dtrange(range1,range2) 'ERROR
End If

DataGrid1.DataMember = dtrange

DataGrid1.Refresh
Label3(0).Caption = "Display: In Range"

End Sub

I am perplexed why a simple SQL command change is throwing such a major spanner in my works. I know that DAO and data environment designers are pretty unpopular in this forum but my work is almost over and this is the last straw that is breaking my back. Help anybody, I am desperate help! Thanks for reading so patiently,
Regards
NS.
 
The DE seems to want it's parameters each in brackets.

Try:

DataEnvironment1.dtrange (range1), (range2)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
WOW it works! it really works, man thanx a lot, salutes to johnwm.
THANK YOU
NS
 
You're welcome. Thanks for the star!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top