CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2005
    Posts
    66

    Arrow Auto display Text...Urgent one

    Hi I had Two Comboboxes

    1) cboitemname
    2) cboitemcode

    I maintained Description of ItemCode & Corresponding Item Name in Access Named as Item_master

    Problem : Suppose i select item Name Then Corressponding Item Code Should populate Automatically or Vice-Versa......

    How do I Code that

    Raj - IDEA Cellular Ltd.

  2. #2
    Join Date
    Nov 2005
    Posts
    4

    Re: Auto display Text...Urgent one

    There are two ways in which u could do it.... since the name and code must be in a single row of the database ....... the time they are added in the combobox they can be recognised by indexex......so once a name is clicked point the item code to the same index as that of the name.....

    the other way u can do it is by simply searching the code combo for your required item.

  3. #3
    Join Date
    Sep 2005
    Location
    Delhi, INDIA
    Posts
    237

    Re: Auto display Text...Urgent one

    HI Raj.. !

    I have done this type of code in my software already...see like this..

    For doing this.. you have to fill first combo sorted on a autonumber field with the Item code. and then another one with Item Description also sorted with the same auto number field. so that Item code and Item Descriptions have same List indexes in both combo boxes..

    Now write a Click event for both combo boxes.. and set the listindex equals to the other's Listindex.. so that if I select 4th Item In Item Code Combo, then it automatically selects the 4th Item iN Item Description..

    Code:
     sub combo1_click() 
    
    	   combo2.listindex = combo1.listIndex
    
    end sub
    
    sub combo2_click()
    
    	   combo1.listindex = combo2.listIndex
    
    end sub
    and I hope it will helps you

    Rahul Kulshreshtha
    ABB
    I'M BACK AGAIN !!
    -------------------------------------------------------------------------
    enjoy the VB !
    If any post helps you, please rate that.
    Always try to findout the Solutions, instead just discussing the problem and its scope!

  4. #4
    Join Date
    Nov 2005
    Posts
    59

    Thumbs up Re: Auto display Text...Urgent one

    Quote Originally Posted by rahul.kul
    HI Raj.. !

    I have done this type of code in my software already...see like this..

    For doing this.. you have to fill first combo sorted on a autonumber field with the Item code. and then another one with Item Description also sorted with the same auto number field. so that Item code and Item Descriptions have same List indexes in both combo boxes..

    Now write a Click event for both combo boxes.. and set the listindex equals to the other's Listindex.. so that if I select 4th Item In Item Code Combo, then it automatically selects the 4th Item iN Item Description..

    Code:
     sub combo1_click() 
    
    	   combo2.listindex = combo1.listIndex
    
    end sub
    
    sub combo2_click()
    
    	   combo1.listindex = combo2.listIndex
    
    end sub
    and I hope it will helps you

    Rahul Kulshreshtha
    ABB
    Rahul is absolutely right! but one more thing is that u must set 'sort' property=false for combo boxes and u must fire the query with order by clause so that both combos will be having same order and whenever u'll assign listindexes of both combos they will give correct corresponding value...bye

  5. #5
    Join Date
    Nov 2005
    Posts
    66

    Re: Auto display Text...Urgent one

    Thanks to Rahul & Manju......

    Have a gr8 time.

  6. #6
    Join Date
    Sep 2005
    Location
    Delhi, INDIA
    Posts
    237

    Re: Auto display Text...Urgent one

    I agreed with Manju !!
    I'M BACK AGAIN !!
    -------------------------------------------------------------------------
    enjoy the VB !
    If any post helps you, please rate that.
    Always try to findout the Solutions, instead just discussing the problem and its scope!

  7. #7
    Join Date
    Apr 2005
    Posts
    159

    Re: Auto display Text...Urgent one

    if u have both the fileds (Itemcode and ItemName) in same table and want to fill both the combos as Form_Load event then use the following code......

    Code:
    'In Gerenal Section of Form Code
    Dim Rsitem as Adodb.Recordset
    
    Private Sub Form1_Load()
    	  Set Rsitem=New Adodb.Recordset
    	  Rsitem.open "Select Itemcode,Itemname from Tablename order   
    				    			  by Itemcode",conn
    	   cboitemcode.clear
    	   cboitemname.clear
    		while Rsitem.EOF=False
    				cboitemcode.Additem (Rsitem!Itemcode)
    				cboitemname.Additem (Rsitem!Itemname)
    				Rsitem.MoveNext
    		wend
    End Sub
    'The above code will make indexes of itemcode and itemname same in both the combos.
    
    'now use the code for index changes done by Rahul

    Quote Originally Posted by manju_ambare
    Rahul is absolutely right! but one more thing is that u must set 'sort' property=false for combo boxes and u must fire the query with order by clause so that both combos will be having same order and whenever u'll assign listindexes of both combos they will give correct corresponding value...bye

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

Featured