what problem in this.........

Reply

Join Date: Jul 2008
Posts: 471
Reputation: abu taher is an unknown quantity at this point 
Solved Threads: 24
abu taher's Avatar
abu taher abu taher is offline Offline
Posting Pro in Training

what problem in this.........

 
0
  #1
Oct 5th, 2009
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Sub QryReport()
  2. On Error Resume Next
  3.  
  4. Dim QryDef As QueryDef
  5. Dim str As String
  6.  
  7. Set QryDef = dbase.QueryDefs("balancesheet")
  8. dbase.QueryDefs.Refresh
  9.  
  10. If Err.Number = 3265 Then
  11. Set QryDef = dbase.CreateQueryDef("balancesheet")
  12. dbase.QueryDefs.Refresh
  13. End If
  14.  
  15.  
  16. str = "select * from [balancesheet]" & _
  17. " where Date ='" & Dtpicker.Value & "'"
  18.  
  19. QryDef.SQL = str
  20. datareport1.Show
  21. End Sub
here show the all data. but the sql command not work. I mean when I select a date the report didn't show that date's data. it show all data. what problem ?
I like sword. Attack or Defense.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 243
Reputation: AndreRet is an unknown quantity at this point 
Solved Threads: 34
AndreRet AndreRet is offline Offline
Posting Whiz in Training
 
0
  #2
Oct 6th, 2009
Try the following syntax -

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. str = "SELECT * from [balancesheet] WHERE Date = DateValue(" & "'" & Dtpicker.Value & ")" & "'"

You can also choose a specific date as in -

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. str = "SELECT * from [balancesheet] WHERE Date => DateValue(" & "'" & Dtpicker.Value & ")" & "'"
Please mark questions as answered when done.

Be the ONE!!!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 471
Reputation: abu taher is an unknown quantity at this point 
Solved Threads: 24
abu taher's Avatar
abu taher abu taher is offline Offline
Posting Pro in Training
 
0
  #3
Oct 6th, 2009
not work. it show the all data.
I like sword. Attack or Defense.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 243
Reputation: AndreRet is an unknown quantity at this point 
Solved Threads: 34
AndreRet AndreRet is offline Offline
Posting Whiz in Training
 
0
  #4
Oct 6th, 2009
str = "select * from [balancesheet] where Date ='" & Dtpicker.Value & "'"
Make sure that you refer to 'Date' above as a field in your database. If you have named your date field something different, then use that name syntax i.e. your date field name is 'DateOfRecord' your code will look something like -

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. str = "SELECT * from balancesheet WHERE DateOfRecord=DateValue(" & "'" & Dtpicker.Value & ")" & "'"str

Also get rid of the [] tags, it is only used when there is a space in your data table name for instance balance sheet will become [balance sheet].

hope this solves your problem.
Please mark questions as answered when done.

Be the ONE!!!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 471
Reputation: abu taher is an unknown quantity at this point 
Solved Threads: 24
abu taher's Avatar
abu taher abu taher is offline Offline
Posting Pro in Training
 
0
  #5
Oct 7th, 2009
not work. more thing:
1. I use query (balancesheet)
2. in dataenvironment: data object - view , object name - balancesheet. in grouping tab - field used grouping - category. in Aggregates tab - name: total, function: sum, Aggregate on: grouping, Field: Amount.
here I do it, to see the sum of category. it work, I mean it show the total sum by category. but the above code i use to see the sum of category by date. I mean I select a date and the total sum will show by this date.
I like sword. Attack or Defense.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 471
Reputation: abu taher is an unknown quantity at this point 
Solved Threads: 24
abu taher's Avatar
abu taher abu taher is offline Offline
Posting Pro in Training
 
0
  #6
Oct 10th, 2009
anybody can help me?
I like sword. Attack or Defense.
Reply With Quote Quick reply to this message  
Reply

Tags
report, sql

Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC