Results 1 to 7 of 7

Thread: multiple combos help

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    45

    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:
    1. sqlstr = "select distinct ProductId from die1 "
    2.    rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic
    3.   ' Combo2.Clear
    4.     Do While Not rs.EOF
    5.      Combo2.AddItem rs.Fields("ProductId").Value
    6.      rs.MoveNext
    7.      Loop
    8.    
    9.    ' Populating combo2 with proper scheduleId's belongs to Product
    10.   rs.Close
    11.   Set rs = Nothing
    12.    
    13.   sqlstr = "select distinct ScheduleId  from die1  where productid= " & Combo2.Text & ""
    14.  
    15.   Set rs = New ADODB.Recordset
    16.   rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    45

    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:
    1. Set con = Nothing
    2.     Set rs = Nothing
    3.     Set con = New ADODB.Connection
    4.     con.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & "Data Source=" & App.Path & "\WRMdatabase.mdb"
    5.     con.Open
    6.    Set rs = New ADODB.Recordset
    7.    sqlstr = "select distinct ProductId from die1 "
    8.    rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic
    9.   ' Combo2.Clear
    10.     Do While Not rs.EOF
    11.      lstpro.AddItem rs.Fields("ProductId").Value
    12.      rs.MoveNext
    13.      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.

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: multiple combos help

    you need to change the field and table names according to your requirements
    VB Code:
    1. If List1.ListIndex <> -1 Then
    2.         MsgBox "No Item Selected !"
    3.         Exit Sub
    4.     End If
    5.     sqlstr = "select Schedules From <Your Table Name> Where ProductID =" & List1.List(List1.ListIndex)
    6.     rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic
    7.     List2.Clear
    8.     Do While Not rs.EOF
    9.         List2.AddItem rs.Fields("Schedule").Value
    10.         rs.MoveNext
    11.     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.


  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    45

    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:
    1. sqlstr = "select ScheduleId From die1 Where ProductID =" & lstpro.List(lstpro.ListIndex)
    2.     rs.Open sqlstr, con, adOpenDynamic, adLockPessimistic
    3.    
    4.     lstall.Clear
    5.     Do While Not rs.EOF
    6.         lstall.AddItem rs.Fields("ScheduleId").Value
    7.         rs.MoveNext
    8.     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.

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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:
    1. 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?

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    45

    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
  •  



Click Here to Expand Forum to Full Width