|
-
Jul 1st, 2006, 06:28 AM
#1
Thread Starter
Member
multiple combos help
HI i need help while i am using multiple combos.I am fetchig values from database and populating in combo1 and in the other combo2 i want to fetch the data wich was havig relation betwee them iam posting my code here once go though it...i am getting an eror like Novalue give for one or more Required parameters
VB Code:
sqlstr = "select distinct ProductId from die1 "
rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic
' Combo2.Clear
Do While Not rs.EOF
Combo2.AddItem rs.Fields("ProductId").Value
rs.MoveNext
Loop
' Populating combo2 with proper scheduleId's belongs to Product
rs.Close
Set rs = Nothing
sqlstr = "select distinct ScheduleId from die1 where productid= " & Combo2.Text & ""
Set rs = New ADODB.Recordset
rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic
-
Jul 1st, 2006, 07:21 AM
#2
Re: multiple combos help
When you first fill Combo2, no item is selected - so there is no text. Before loading the data for the second combo, you need to either select an item via code (eg: Combo2.ListIndex=1) or wait until the user makes a selection.
By the way, if the productid field is a text/char field, you need to put ' on each side of the value.
-
Jul 2nd, 2006, 11:13 PM
#3
Thread Starter
Member
Re: multiple combos help
Hi now i was said by my sir to use listboxes to get the result.Here again i require 2 listboxes and one for getting produtcts(datatype text) and the other one after clicking the any of the product i should get the schedules and passes under it...How it can be possible? Plz help me
My code is
VB Code:
Set con = Nothing
Set rs = Nothing
Set con = New ADODB.Connection
con.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & "Data Source=" & App.Path & "\WRMdatabase.mdb"
con.Open
Set rs = New ADODB.Recordset
sqlstr = "select distinct ProductId from die1 "
rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic
' Combo2.Clear
Do While Not rs.EOF
lstpro.AddItem rs.Fields("ProductId").Value
rs.MoveNext
Loop
until there i am viewing my all products wich were there but after clicking any products,the schedules and passes shld visible...How this can be done all are Text datatypes.
-
Jul 2nd, 2006, 11:37 PM
#4
Re: multiple combos help
you need to change the field and table names according to your requirements
VB Code:
If List1.ListIndex <> -1 Then
MsgBox "No Item Selected !"
Exit Sub
End If
sqlstr = "select Schedules From <Your Table Name> Where ProductID =" & List1.List(List1.ListIndex)
rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic
List2.Clear
Do While Not rs.EOF
List2.AddItem rs.Fields("Schedule").Value
rs.MoveNext
Loop
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jul 3rd, 2006, 12:50 AM
#5
Thread Starter
Member
Re: multiple combos help
HI,Ganesh I had atached ur code in my project but the followinf error occurs..
No Value Given For One or more Required Parameters.
My code is like
VB Code:
sqlstr = "select ScheduleId From die1 Where ProductID =" & lstpro.List(lstpro.ListIndex)
rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic
lstall.Clear
Do While Not rs.EOF
lstall.AddItem rs.Fields("ScheduleId").Value
rs.MoveNext
Loop
Here i feel mycode is not fetching the value of ScheduleId From database coz if i put msgbox to print nothing is appearing in place of ScheduleId.So Kindly help me..
Last edited by Admirer; Jul 3rd, 2006 at 01:39 AM.
-
Jul 3rd, 2006, 05:19 AM
#6
Re: multiple combos help
It's not clear from your post if ProductId is text or not - if it is, you need to put ' around the value, eg:
VB Code:
sqlstr = "select ScheduleId From die1 Where ProductID = '" & lstpro.List(lstpro.ListIndex) & "'"
If that doesn't solve it, answer these questions:
1. What line does the error occur on?
2. Where is this code being run? (is it after an item is selected in the list?)
3. What data type is ProductId?
-
Jul 3rd, 2006, 07:14 AM
#7
Thread Starter
Member
Re: multiple combos help
Hi
Tanq Very Much Now the problem is solved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|