@sknaina
Hi
First of all you need to have a serious look at how SQL server stores dates. The absolute mechanics of that I will not go into, as it is fully documented in Books Online the SQL Server help reference... so read up on that. You will then appreciate the issues involved as relates to
casting values (
particularly dates) to an acceptable format.
Suffice it to say this the
clues are in the amendments I post back to you below:
Secondly look at your SQL you are including in that a column a concatenation of two fields to produce a column that will bear no column name (not that this stops the code in fairness but. I have amended that to reflect at least something meaningful instead of the usual
'Expr1' that would ordinarily be returned
At this point in time I am not particulary interested in the functionality of your logic flow concerning label visibility, saving and stuff like that so much as the issue to get that listbox populated in line with the value expressed in the
TxtChallanDate textbox, afterupdate of the amount entered into the textbox
tXtamount
Now look at the following pasted code and examine the differences between this and your last post.
You will see where I have included the apostrophe wrapping the date value. Yes... I know the convention for referring to dates is the
# wrapper usually however see for yourself, if you create a simple view in an ADP the convention used in the query grid automatically inserts the apostrophe (try it for yourself). You try and use the apostrophe instead and see how far it gets you......absolutely nowhere!
Insofar as relates to your stored procedure, you need to deal with the date value parameter passed in terms of
Casting and Converting (which you can read up on) so that the parameter value passed in meets with the agenda required to compare correctly against the way in which a date is stored, which I assume to be datetime data type on the server in your case.
The storage value is best looked at using Query Analyser in which you will see dates stored 'back to front', year first and always including the time portion. Again I won't go into the logic of this as it is fully documented.
If you look at your table data in Access it does not show you these differences because Access knows how to present your date value to you, formatted according to your localised regional settings
The revised edition to populate your listbox...
- Me!Lst_Challan.RowSource = "Exec dbo.DailyChallan '" & Format(Me.TxtChallanDate, "mm/dd/yyyy") & "'"
The revised edition of your stored procedure...
- CREATE Procedure dbo.DailyChallan
-
@Pdate datetime
-
AS
-
SELECT Challanno,depositor,HDc_EconomicT.Economic+'-'+HDc_EconomicT.Engdesc AS MyExtraColumn,Amount
-
FROM HDC_ChallanT, HDC_EconomicT
-
WHERE HDC_challanT.Economic=Hdc_EconomicT.EcoiD
-
AND HDC_ChallanT. ChallanDate=CONVERT(DATETIME,@Pdate, 102)GO