473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

listbox with parameter sp of unbound control of forms

11
Hi everyone,
I've a A2003 adp & mssql2k base application Where I want to use List box with control source parameter sp . My form is bound but forms controls are unbound. now i describe what i've follow to achieve the task
forms record source:: Select * from HDC_ChallanT
listbox record source:: DailyChallan

Expand|Select|Wrap|Line Numbers
  1. CREATE Procedure dbo.DailyChallan
  2. @Pdate datetime
  3. AS
  4. Select Challanno,depositor,HDc_EconomicT.Economic+'-'+HDc_EconomicT.Engdesc,Amount  
  5. from HDC_ChallanT, HDC_EconomicT
  6. Where HDC_challanT.Economic=Hdc_EconomicT.EcoiD
  7. AND HDC_ChallanT. ChallanDate=@Pdate
  8. GO
when i open this form it prompts access default form then I set forms input-parameter :@pdate datetime =forms!HDC_ChallanDetailf!txtChallandate
now it prompts "Bad parameter @pdate"
would any one suggest me what ive to do to success this project .Any suggestion would be highly appreciated.
May 10 '10 #1
5 2546
Jim Doherty
897 Expert 512MB
@sknaina
Hi

The InputParameters property of a form is intended to pass parameters to the SQL Server to restrict any recordset supplied from the server intended to act as the recordsource for your FORM only. Think of listboxes and comboboxes as entirely separate and unconnected from this

To use a stored procedure to populate a listbox (or combobox) you simply give the listbox its rowsource at the appropiate point in time. ie:

The syntax for passing the rowsource of a combo is as simple as below where datecriteria is a variable date value passed and concatenated to that string line. The value for this variable you can set, in code, at whatever point you wish, whether that be hard coded or taken from the value of a textbox somewhere or other on screen

Me!YourListboxName.RowSource = "EXEC dbo.dbo.DailyChallan " & datecriteria

1) If the relevant listbox or combobox is page2 of a tab control for instance, then don't load until till page2 is viewed and so on , or if 'always in view' not until the control gets the focus.

2) The purpose of this logic at 1) is this:- think network load. There is no point populating any list over a network if you do not intend to use it. Yes I know, some might argue but its only a small list...yes, but it is one less server process to profile when and if performance ever becomes an issue in a multi user wide area network environment when your app becomes the size of a house. :)

So... essentially then an EXEC statement command line is passed as a string command to the SQL server and it in turn 'executes' the relevant stored procedure returning the dataset requested to the control

Regards
May 10 '10 #2
sknaina
11
@Jim Doherty
Jim thanks for your reply
accordance to your suggestion create a Private function and call this function on after event of form control. But no desired result achieved. that means listbox show nothing below I would post both code
Private Function To execute the parameter Sp.
Expand|Select|Wrap|Line Numbers
  1. Private Function ListUpdate()
  2. Me!Lst_Challan.RowSource = "Exec dbo.DailyChallan " & Format$(Me.TxtChallanDate, "mm/dd/yyyy")
  3. End Function
  4.  
After update Event

Expand|Select|Wrap|Line Numbers
  1. Private Sub tXtamount_AfterUpdate()
  2.         If CheckSave = False Then Exit Sub ' its a function to validate all required fields are filled up
  3.             If ChallanSave = True Then ' its function to execute challan save paramenter sp
  4. Me.LblYes.Visible = True 'MsgBox
  5.             ListUpdate ' its function to execute the parameter Sp for Listbox Population
  6.             PartialClear ' its function to clear text box value after saving data
  7. Else
  8.             Me.LblNo.Visible = True 'MsgBox
  9.         End If
  10.             End Sub
  11.  
May 11 '10 #3
Jim Doherty
897 Expert 512MB
@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...

Expand|Select|Wrap|Line Numbers
  1. Me!Lst_Challan.RowSource = "Exec dbo.DailyChallan '" & Format(Me.TxtChallanDate, "mm/dd/yyyy") & "'"
The revised edition of your stored procedure...

Expand|Select|Wrap|Line Numbers
  1. CREATE Procedure dbo.DailyChallan 
  2. @Pdate datetime 
  3. AS 
  4. SELECT Challanno,depositor,HDc_EconomicT.Economic+'-'+HDc_EconomicT.Engdesc AS MyExtraColumn,Amount   
  5. FROM HDC_ChallanT, HDC_EconomicT 
  6. WHERE HDC_challanT.Economic=Hdc_EconomicT.EcoiD 
  7. AND HDC_ChallanT. ChallanDate=CONVERT(DATETIME,@Pdate, 102)GO
May 11 '10 #4
sknaina
11
@Jim Doherty
Jim, first of all sorry for late response due to we have lot of power problem. Any way, many many thanks for your meaningful information . And Once again Sorry for my SP (this was unintentional mistake). AND last of all, it works fine.

Thanks for your great co-operation.

>>>>>>Naina<<<<<<<<<
May 11 '10 #5
Jim Doherty
897 Expert 512MB
@sknaina
You are welcome and I am pleased you got this working.
Thankyou for posting back the result :)
May 12 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: mork | last post by:
I've got a form with AllowEdit = False. On it is a tab control, one of the tab pages has an unbound listbox which fetches data from another table. I am unable to select items in the listbox. ...
2
by: Georges Heinesch | last post by:
Hi. I cannot change the value of an unbound control (txtSR and txtSS) within a sub call. I explain ... my sub (SRSS_set) takes the date (type date) as input, and returns 2 values (type time). ...
0
by: Bob Bykerk | last post by:
Hyperlinks work fine when using bound controls but when I try to get one to work on an unbound control (with hyperlink? = true) I can't insert a hyperlink or use the data as a hyperlink. I have...
3
by: Trevor Hughes | last post by:
I am trying to resolve a problem I'm experiencing in Access 2000. I have an unbound control which is set be code on the open event of a form. However when I try to subsequently run some code...
1
by: Jim M | last post by:
To prevent data corruption I have replaced a memo field on my form with an unbound control on my form that I populate with a function that fills it from a memo field from my table. When the form is...
8
by: cannen | last post by:
Hi all, Access Newbie here with I'm sure is an easily answered question. I have a form that has a tab control with a listbox called lstVacations. What iam attempting to do is click a record in...
2
by: simon | last post by:
I have userControl and inside this control I have ListBox. Now I would like to set the properties and bind with database this listBox in my control anywhere on the pages, where I use my control....
0
by: Barbara Schmidt | last post by:
Hello, if I get the data from db with sqldatasource-control, how to show this data to an unbound control, so for instance: label1.text=sqldatasourceWHAT-TO-DO-NOW Thanks Barbara
3
by: scott_baird | last post by:
Probably something simple, but it's driving me up the wall... In a report, I have an unbound control that is the total of 2 other bound controls (currency) as follows: unbound control =cash1 +...
0
JAMBAI
by: JAMBAI | last post by:
I am using a OLE unbound Control to Embed the word document in the form load, event like this http://support.microsoft.com/kb/209990 and When i double clicks (In Place activation), the documents...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.