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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SORTING DATA BY DATA

Status
Not open for further replies.

Kevsim

Instructor
Apr 18, 2000
385
0
0
AU
Using a form with 2 Text boxes, one for Start Date and the other for End Date and a Command button, I wish to sort and view all records when I press the command button after the start and finish dates are entered into the text boxes associated with the query. I would do this using the on click event of the command button. I have included some code that does not work. As I am not sure how to do this I would appreciate some assistance.
[T_FinalData] is the table and [DateWorkDone] is the field in the table.

Private Sub Command34_Click()
Dim SQLst, Sdate, Edate
Sdate = Text30
Edate = Text32
SQLst = &quot;SELECT [DateWorkDone] FROM [T_FinalData]&quot; & &quot;WHERE [Sdate] >= DateWorkDone And [End Date]<= DateWorkDone &quot;
End Sub
kevsim
 
Dear Kivim,

As I UnderStood Ur SQLS Should Be Like This,

SQLst = &quot;SELECT * FROM [T_FinalData] WHERE DateWorkDone Between Sdate And Edate&quot;

I hope That Would Help,

Good Luck
Haitham
 
Haitham, Thanks for the info, I am still having making the records sort. Below is the code I am using at present in the On Click event of a button. When I press the button an error message appears saying &quot;Too few paramaters.Expected 2&quot;, this happens at the line Set Work Done. Could you please assist me further.

Private Sub Command90_Click()
Dim SQLst As String
Dim Sdate, Edate
Dim WorkDone
Sdate = Text30
Edate = Text32
SQLst = &quot;SELECT * FROM [Q_FinalData] WHERE DateWorkDone Between Sdate And Edate&quot;
Set WorkDone = CurrentDb.OpenRecordset(SQLst)
End Sub
 
ok, in this code your making a recordset and not doing any thing with it...

Are you leaving some of the code out??

Also, you can put an order clause in the sql...

SQLst = &quot;SELECT * FROM [Q_FinalData] WHERE DateWorkDone Between Sdate And Edate Order on DateWorkDone&quot;

but if this is a bound form then this still wont do any thing...

--James

junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top