Link to home
Start Free TrialLog in
Avatar of demoniumz
demoniumz

asked on

Query needed vb 2005

Hello experts.I have a problem  with a form.I need a query when i choose a suplier from a combobox to show only the products that belong to this supplier only.

I select asuplier from a combobox and the product choose is in  another combobox.

So if i choose suplier x in the combobox i must only able to choose the products from the other combobox  that belong to the spicify supplier .

I am  using vb 2005 linked from  ms access 2003 and i am using binding navigator

Thnks expects i  want a example and a tutorial about queris general.

Regards demoniumz
Avatar of josephwalsh
josephwalsh
Flag of Ireland image

Sample Code PRovided ebelow :

Private Sub cboProductID_GotFocus()
On Error GoTo Error_cboProductID_GotFocus

    Dim strsql As String

    With Me
        If IsNull(!cboSupplierID) Or !cboSupplierID = "" Then
            MsgBox "You must supply a SupplierID before a ProductID."
            !cboSupplierID.SetFocus
            Exit Sub
        End If
        strsql = "SELECT * FROM tblProducts WHERE strSupplierID = '" & !cboSupplierID & "'"
        strsql = strsql & " ORDER by intProductID"
        !cboProductID.RowSource = strsql
        !cboProductID.Requery
        '!cboProductID.Dropdown
    End With

Exit_cboProductID_GotFocus:
    Exit Sub
   
Error_cboProductID_GotFocus:
    MsgBox "Error No : " & Err.Number & "Desc : " & Err.Description
    Resume Exit_cboProductID_GotFocus

End Sub

Avatar of demoniumz
demoniumz

ASKER

i must  write these in  the form  code sure?
Right click on the product combo box, click properties, click events tab, click on got focus, from drop down click event procedure.
The vb code will appear and you can paste the above into it.
Make sure Private Sub cboProductID_GotFocus() & End Sub are not duplicated
click events tab, click on got focus, from drop down click event procedure.

i cant found it : explain pls
See attached picture
untitled.bmp
hehee this is ms office 2007 true? so  from ms acces i must add the query?
my form is in VB 2005 not in ms access
Are you using Visual Studio 2005 (VB) with MSAccess as the Data Store ?
Can you show me a sample of your code ?

ok here is all the code
ublic Class NicolaouPurchase
 
    Private Sub PurchaseBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PurchaseBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.PurchaseBindingSource.EndEdit()
        Me.PurchaseTableAdapter.Update(Me.NicolaouDBDataSet.Purchase)
 
    End Sub
   
    Private Sub PurchasedetailsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PurchaseBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.PurchasedetailsBindingSource.EndEdit()
        Me.PurchasedetailsTableAdapter.Update(Me.NicolaouDBDataSet.Purchasedetails)
 
    End Sub
    Private Sub NicolaouPurchase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      
    End Sub
 
 
    Private Sub Addpr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Addpr.Click
        Dim bsource As BindingSource = Me.PurchasedetailsDataGridView.DataSource
        Dim ds As DataSet = DirectCast(bsource.DataSource, DataSet)
 
        Dim dr As DataRow = ds.Tables("PurchaseDetails").NewRow
        dr("Purchaseid") = PurchaseIDTextBox.Text
        dr("Productid") = ProductIDComboBox1.SelectedValue
        dr("UnitPrice") = UnitPriceTextBox1.Text
        dr("Quantity") = QuantityTextBox1.Text
        dr("Productname") = ProductNameTextBox1.Text
 
        dr("Total") = Convert.ToString(UnitPriceTextBox1.Text.ToString()) * Convert.ToString(QuantityTextBox1.Text.ToString())
 
        ds.Tables("PurchaseDetails").Rows.Add(dr)
 
 
        TotalSum()
    End Sub
    Private Sub TotalSum()
        Dim sum As Decimal = 0
        For Each row As DataGridViewRow In PurchasedetailsDataGridView.Rows
            row.Cells(5).Value = row.Cells(3).Value * CDec(row.Cells(4).Value)
            sum += row.Cells(5).Value
        Next
        Me.TotalTextBox.Text = sum
        Me.TotalTextBox.Text = sum.ToString("¬0.00")
 
 
        PurchasedetailsDataGridView.Columns(5).DefaultCellStyle.Format = ("¬0.00")
    End Sub
 
    
 
    Private Sub addrec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addrec.Click
        Me.NicolaouDBDataSet.Purchasedetails.Clear()
        TotalTextBox.Text = String.Empty
        PurchaseBindingSource.AddNew()
 
    End Sub
 
 
 
    Private Sub movenext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movenext.Click
        PurchasedetailsBindingSource.MoveNext()
    End Sub
 
    Private Sub moveprevius_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles moveprevius.Click
        PurchasedetailsBindingSource.MovePrevious()
 
    End Sub
 
    Private Sub movelast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movelast.Click
        PurchasedetailsBindingSource.MoveLast()
    End Sub
 
    Private Sub movefirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movefirst.Click
        PurchasedetailsBindingSource.MovePrevious()
    End Sub
 
    Private Sub delrec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delrec.Click
        PurchasedetailsBindingSource.RemoveCurrent()
    End Sub
 
    Private Sub delbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delbut.Click
 
        PurchasedetailsDataGridView.Rows.Remove(PurchasedetailsDataGridView.CurrentRow)
 
        TotalSum()
    End Sub
 
    Private Sub clearbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearbut.Click
        Me.NicolaouDBDataSet.Purchasedetails.Clear()
    End Sub
 
    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        'TODO: This line of code loads data into the 'NicolaouDBDataSet.Purchasedetails' table. You can move, or remove it, as needed.
        Me.PurchasedetailsTableAdapter.Fill(Me.NicolaouDBDataSet.Purchasedetails)
        'TODO: This line of code loads data into the 'NicolaouDBDataSet.Products' table. You can move, or remove it, as needed.
        Me.ProductsTableAdapter.Fill(Me.NicolaouDBDataSet.Products)
        'TODO: This line of code loads data into the 'NicolaouDBDataSet.Suppliers' table. You can move, or remove it, as needed.
        Me.SuppliersTableAdapter.Fill(Me.NicolaouDBDataSet.Suppliers)
        'TODO: This line of code loads data into the 'NicolaouDBDataSet.Purchase' table. You can move, or remove it, as needed.
        Me.PurchaseTableAdapter.Fill(Me.NicolaouDBDataSet.Purchase)
 
    End Sub
 
    
 
    
 
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
 
    End Sub
End Class

Open in new window

is not easy to   fix it to many errors
Error      2      Handles clause requires a WithEvents variable defined in the containing type or one of its base types.      D:\s\Nicolaou\NicolaouPurchase.vb      131      105      Nicolaou

Error      1      Name 'cShared' is not declared.      D:\s\Nicolaou\NicolaouPurchase.vb      20      33      Nicolaou



Public Class NicolaouPurchase
 
    Private Sub PurchaseBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PurchaseBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.PurchaseBindingSource.EndEdit()
        Me.PurchaseTableAdapter.Update(Me.NicolaouDBDataSet.Purchase)
 
    End Sub
   
    Private Sub PurchasedetailsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PurchaseBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.PurchasedetailsBindingSource.EndEdit()
        Me.PurchasedetailsTableAdapter.Update(Me.NicolaouDBDataSet.Purchasedetails)
 
    End Sub
    Private Sub NicolaouPurchase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Cursor = Cursors.WaitCursor
 
        'Loads the data
        Dim dsData As DataSet = cShared.CreateDataSet()
 
        'Creates a relation between the 2 DataTables
        dsData.Relations.Add("relsuppliersproducts", _
                        dsData.Tables("suppliers").Columns("supplierID"), _
                        dsData.Tables("Products").Columns("Productid"))
 
        'Binds the combos
        With SupplierIDComboBox
            .DisplayMember = "contactname.Description"
            .ValueMember = "supplierid"
            .DataSource = SuppliersBindingSource
        End With
 
        With ProductIDComboBox1
            .DisplayMember = "productname.relsuppliersproducts.Description"
            .ValueMember = "Poductid"
            .DataSource = ProductsBindingSource
        End With
 
        Me.Cursor = Cursors.Default
    End Sub
 
 
    Private Sub Addpr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Addpr.Click
        Dim bsource As BindingSource = Me.PurchasedetailsDataGridView.DataSource
        Dim ds As DataSet = DirectCast(bsource.DataSource, DataSet)
 
        Dim dr As DataRow = ds.Tables("PurchaseDetails").NewRow
        dr("Purchaseid") = PurchaseIDTextBox.Text
        dr("Productid") = ProductIDComboBox1.SelectedValue
        dr("UnitPrice") = UnitPriceTextBox1.Text
        dr("Quantity") = QuantityTextBox1.Text
        dr("Productname") = ProductNameTextBox1.Text
 
        dr("Total") = Convert.ToString(UnitPriceTextBox1.Text.ToString()) * Convert.ToString(QuantityTextBox1.Text.ToString())
 
        ds.Tables("PurchaseDetails").Rows.Add(dr)
 
 
        TotalSum()
    End Sub
    Private Sub TotalSum()
        Dim sum As Decimal = 0
        For Each row As DataGridViewRow In PurchasedetailsDataGridView.Rows
            row.Cells(5).Value = row.Cells(3).Value * CDec(row.Cells(4).Value)
            sum += row.Cells(5).Value
        Next
        Me.TotalTextBox.Text = sum
        Me.TotalTextBox.Text = sum.ToString("¬0.00")
 
 
        PurchasedetailsDataGridView.Columns(5).DefaultCellStyle.Format = ("¬0.00")
    End Sub
 
    
 
    Private Sub addrec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addrec.Click
        Me.NicolaouDBDataSet.Purchasedetails.Clear()
        TotalTextBox.Text = String.Empty
        PurchaseBindingSource.AddNew()
 
    End Sub
 
 
 
    Private Sub movenext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movenext.Click
        PurchasedetailsBindingSource.MoveNext()
    End Sub
 
    Private Sub moveprevius_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles moveprevius.Click
        PurchasedetailsBindingSource.MovePrevious()
 
    End Sub
 
    Private Sub movelast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movelast.Click
        PurchasedetailsBindingSource.MoveLast()
    End Sub
 
    Private Sub movefirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movefirst.Click
        PurchasedetailsBindingSource.MovePrevious()
    End Sub
 
    Private Sub delrec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delrec.Click
        PurchasedetailsBindingSource.RemoveCurrent()
    End Sub
 
    Private Sub delbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delbut.Click
 
        PurchasedetailsDataGridView.Rows.Remove(PurchasedetailsDataGridView.CurrentRow)
 
        TotalSum()
    End Sub
 
    Private Sub clearbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearbut.Click
        Me.NicolaouDBDataSet.Purchasedetails.Clear()
    End Sub
 
    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        'TODO: This line of code loads data into the 'NicolaouDBDataSet.Purchasedetails' table. You can move, or remove it, as needed.
        Me.PurchasedetailsTableAdapter.Fill(Me.NicolaouDBDataSet.Purchasedetails)
        'TODO: This line of code loads data into the 'NicolaouDBDataSet.Products' table. You can move, or remove it, as needed.
        Me.ProductsTableAdapter.Fill(Me.NicolaouDBDataSet.Products)
        'TODO: This line of code loads data into the 'NicolaouDBDataSet.Suppliers' table. You can move, or remove it, as needed.
        Me.SuppliersTableAdapter.Fill(Me.NicolaouDBDataSet.Suppliers)
        'TODO: This line of code loads data into the 'NicolaouDBDataSet.Purchase' table. You can move, or remove it, as needed.
        Me.PurchaseTableAdapter.Fill(Me.NicolaouDBDataSet.Purchase)
 
    End Sub
 
    
    Private Sub btnShowValues_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowValues.Click
        Dim intSelectedproductid As Integer
        Dim intSelectedsupplierid As Integer
 
        If SupplierIDComboBox.SelectedValue Is Nothing Then
            intSelectedsupplierid = -1
        Else
            Try
                intSelectedsupplierid = Convert.ToInt32(SupplierIDComboBox.SelectedValue)
            Catch ex As Exception
                intSelectedsupplierid = -1
            End Try
        End If
 
        If ProductIDComboBox1.SelectedValue Is Nothing Then
            intSelectedproductid = -1
        Else
            Try
                intSelectedproductid = Convert.ToInt32(ProductIDComboBox1.SelectedValue)
            Catch ex As Exception
                intSelectedproductid = -1
            End Try
        End If
 
        MessageBox.Show("The ID of the selected Country is : " + intSelectedsupplierid.ToString + Environment.NewLine + _
                        "The ID of the selected State/Province is : " + intSelectedproductid.ToString, _
                        "Demo application", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub
 
    Private Sub ProductIDComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductIDComboBox1.SelectedIndexChanged
 
    End Sub
End Class
    
 
    

Open in new window

my  dataset is NicolaouDBDataSet i am  using database from ms access 2003 llinked to vb 2005
cShared is the name of the class I use to create the in-memory dataset.

All your tableAdpater's Fill method should be moved to the Load event.
>>is not easy to   fix it to many errors

you surely don't have errors in the original demo (before you start modifying it).
in the original demo is not  have error  in mine yes
Private Sub NicolaouPurchase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Cursor = Cursors.WaitCursor

        'Loads the data

        Dim Nicolaoudb As DataSet = cShared.CreateDataSet()
        'Creates a relation between the 2 DataTables
        Nicolaoudb.Relations.Add("relsuppliersproducts", _
                        Nicolaoudb.Tables("suppliers").Columns("supplierID"), _
                        Nicolaoudb.Tables("Products").Columns("Productid"))

        'Binds the combos
        With SupplierIDComboBox
            .DisplayMember = "contactname.Description"
            .ValueMember = "supplierid"
            .DataSource = SuppliersBindingSource
        End With

        With ProductIDComboBox1
            .DisplayMember = "productname.relsuppliersproducts.Description"
            .ValueMember = "Poductid"
            .DataSource = ProductsBindingSource
        End With

        Me.Cursor = Cursors.Default
    End Sub

cshared is not decleare!!!!!!!!!!!!!!!!!!!!!!!
>>cshared is not decleare

again, cShared is my class that contains the CreateDataset. You don't have it so replace that line with your Fills method.
This constraint cannot be enabled as not all values have corresponding parent values.
 
NicolaouDBDataSet.Relations.Add("relsuppliersproducts", _
                        NicolaouDBDataSet.Tables("suppliers").Columns("supplierID"), _
                        NicolaouDBDataSet.Tables("Products").Columns("Productid"))

my table is suppliers and products  dataset is NIcolaouDB

THE two combobox is supplieridcombobox and productid combobox
i have a combox and 2-3 textboxes that moved from combobox is these the problem?
the relation you create has to bind fields with the same values. Your Products table surely have a SupplierID column. This is the field you need to relate:

NicolaouDBDataSet.Relations.Add("relsuppliersproducts", _
                        NicolaouDBDataSet.Tables("suppliers").Columns("supplierID"), _
                        NicolaouDBDataSet.Tables("Products").Columns("supplierID"))
A relation already exists for these child columns.
a relation in the database or in the dataset? it has to exist in the dataset. if it exist, just provide appropriate names to the binding of the combobox and it will work.
can i  uploadi it here  to help me fix it
You have a fully working example. You should be able to do it. If you replace the name of the fields and relations, it just works. If you upload it, I won't be able to test it as I don't have the matching database!
i can upload  also the database

have you seriously tried to fix it yourself? it should be really simple. a lot of people have downloaded my demo and made it fit their own needs. you can try to upload it.

btw, this become consultation, where do I send the bill ;)
The aplication i cant upload it now cause no time  i must go to work tonight i upload it thnks
NicolaouDB.mdb
lol sent it to me the bill
i upload my  aplications pls help me to fix it

Regards demoniumz
s.zip
are you kidding me? 16.5 mb?!?!?! If I open this, I will have to send an invoice for real!

Can you create a single form with your dataset already opened?
can i copy the form   to another aplication? yes> how?
open Windows Explorer and copy the 2 files to another folder.
the 2 files which?
for how long have you been using .Net?

yourForm.vb + yourform.designer.vb
for 1 year now

http://rapidshare.com/files/233040805/New_Folder.zipx.html

here downlad it please
for 1 year now

http://rapidshare.com/files/233040805/New_Folder.zipx.html

here downlad it please
thnks for the help
is zipx a special format?

I tried to rename it as .zip and I cannot extract any files from it.
you haven't created something I can work from! I asked for you to create a single form application with your dataset already opened.

And I continue to say that if you are a programmer, you should be able to replace the name of the columns from my example with yours.
waita littile i have poblem with save n a the form please
http://rapidshare.com/files/235853093/Nicolaou.rar.html

Here is the new upload i make  pls help

Regards demoniumz
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
can u explain me something please
1.What are u menawith these??
First, the supplier value in the products table was empty! I had to fill this column directly in the database.
You mean that no  supplier exist in  the database? so you add a new one?

2.Then I wasn't really sure about your 2 combos. So I have added 2 new combo box to the form. I have named the first one as cboSupplier and the second one as cboProduct (without modifying any other properties).

You mean the combobox i add is  in wrong way how i can corected?And how you add  . DisplayMember = "Suppliers.SuppliersProducts.ProductName

3 can u upload back the solution so i can  see it please??

Thnks for the help i apreciate.When  i try the solution with  my combobox i get  in the two comboboxs
System.Data.DataviewManagerListItemTypeDescriptor why>?


please upload  the solution  online so  i can  check my problem i can  move the two combobox  but the  textboxes that moved bedore  can t changed.

Regards demoniums

ps see to be errors in the type of i  make the relation  because is like something they stack i cant close the form (must go to run in vb  to stop the form.Please upload the solution
Now is working 100% but the problem is that i need to move the textboxes that they moved as before so  i  can see the unit price and etc how?
emoreau when the combobox  select for example Royal&rothmans to see the details of the products and the company that belong to it?????
ok apparently you got it working so I won't need to upload anything.

Using the technique I have used here (to set the DisplayMember on the relation), the order is ALWAYS from the parent to child (Suppliers to Products in your case).

If you need to modify that, you will need to use solution #2 from my article. Handle the SelectedIndexChanged event of the product combo to fill the supplier combo.
i understand you but how  i set it  when the combobox Royals&Rothmans selected to appera the details of the supplier in the textboxes?

That i ask can u explain me?
I never bind controls like you do.

in the SelectedIndexChanged of the supplier combo, fill the textbox you need. it currently does not follow because you manually feed the combo. Otherwise, you would need to synchronize the binding source but, as I said, I never bind controls like you do.
In the SelectedIndexChanged of the supplier combo, fill the textbox you need what are u mean  fill ?how to  fill it?
And how i  synchronize the binding source?
apologize but i am new to vb
I have spent enough time on this and I don't see the end of all your questions. You asked about the combo box and we are now at textbox and databinding. sorry but I don't have that much time.
ok ok
Hello again apolozise i  ask  again but i need to know if your in  the situation to  help me  complete something.I fill  the combobox the Supplier combobox and the solution you provide to me is working also i  make the textboxes to work for supplier but the textboxes for Productid combobox is not moved can u explain me.

Also the Image in the supplier that i want to change is not changed why?>

Thnks for help if you are not in situation to help me i close  the question now

Regards demoniumz

 Private Sub SupplierIDComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SupplierIDComboBox.SelectedIndexChanged
        If Me.SupplierIDComboBox.SelectedIndex <> -1 Then
 
            Dim dr As DataRow = Me.NicolaouDBDataSet.Suppliers.Rows.Find(Me.SupplierIDComboBox.SelectedValue)
            If dr IsNot Nothing Then
                Me.SupplierIDTextBox.Text = dr.Item(0).ToString
                Me.ContactTitleTextBox.Text = dr.Item(1).ToString
                Me.CompanyNameTextBox.Text = dr.Item(2).ToString
                Me.PhotoPictureBox = dr.Item(3).ToString
            End If
 
        End If
 
    End Sub
 
    Private Sub ProductIDComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductIDComboBox.SelectedIndexChanged
        If Me.ProductIDComboBox.SelectedIndex <> -1 Then
 
            Dim dr As DataRow = Me.NicolaouDBDataSet.Products.Rows.Find(Me.ProductIDComboBox.SelectedValue)
            If dr IsNot Nothing Then
                Me.DescriptionTextBox.Text = dr.Item(0).ToString
 
 
            End If
 
        End If
    End Sub

Open in new window

for your picturebox, you need to convert to byte array to an image:

                If Convert.IsDBNull(dr.Item("Photo")) Then
                    Me.PhotoPictureBox.Image = Nothing
                Else
                    Me.PhotoPictureBox.Image = ConvertTo(dr.Item("Photo"))
                End If

    Public Overloads Function ConvertTo(ByVal ImageArray As Byte()) As System.Drawing.Image
        Dim objMS As New System.IO.MemoryStream

        objMS.Write(ImageArray, 0, ImageArray.Length)
        Try
            ConvertTo = System.Drawing.Image.FromStream(objMS)
        Catch ae As System.ArgumentException
            Return Nothing
        End Try
    End Function
for the other textboxes
It is working if you set the to the correct item:

        If Me.ProductIDComboBox.SelectedIndex <> -1 Then

            Dim dr As DataRow = Me.NicolaouDBDataSet.Products.Rows.Find(Me.ProductIDComboBox.SelectedValue)
            If dr IsNot Nothing Then
                'Me.DescriptionTextBox.Text = dr.Item(0).ToString
                Me.DescriptionTextBox.Text = dr.Item("ProductName").ToString
                Me.UnitPriceTextBox.Text = dr.Item("UnitPrice").ToString
                Me.QuantityTextBox.Text = dr.Item("QtyPerUnit").ToString

            End If

        End If
Not working
The Product textboxes is not moved nothing working except Productidcombobox
can you reupload your .zip file HERE and tell me EXACTLY what is not working?
Yes ofcourse i can reupload it but  The textboxes that needed in order to insert  a product in the datagridview in the form is not work only the Productidcombobox.

ps in  my project the relation from suplier to productid combobox is working here in example only suplieridcombobox appea to working

download from herehttp://rapidshare.com/files/236966381/Nicolaou.zipx.html
is a problrm with  winzip so  try to download to  rar from here please
I reupload it  now here

http://rapidshare.com/files/236968930/Nicolaou.rar.html
I have reached the limit of a free account. Upload it HERE.
i have problem with winzip and winrar to upload it here so i upload it in mediafire  please download from there apologize for any problems

http://uploading.com/files/4OMC0S3S/Nicolaou.rar.html
What is the problem exactly? Your textbox and your image seems to work fine.
Yea the textboxes from the supplieridcombobox is work  fine.You see  bellow datagrid view the Product id combobox?They are some textboxes Productname Product Quantity and etc these textboxes before is movved in order  to add a product inside the datagridview now is not worked.

I want to display the details of each  product  as the Supplier textboxes
when I select a product in the Product combo, the name, description and price are changing in the textboxes.

Anyway, it is not related to the original question about the 2 comboboxes.
When  you selected a suplier  from the combobox1 and the suplier2 display the product that belong to the supplier the  name description and price is not changing that i  ask  why
Apologize here i corect what i  tell before

you selected a suplier  from the combobox1 and the combobox2 display the product that belong to the supplier the textboxes   name description and price is not changing that i  ask  why
I don't understand. In the last sample you sent, the price is changing.

Also, what are combobox1 and combobox2 refering to? You have no controls with that name.

In order to help, can I ask you to make yourself clear. Without clear indication I am losing my time.
ok wait
ok first of all apologize for the sample i sent wrong.but the Product id combobox is changed becase if you see is using data bound  items if not and use  the code  you provide the  textboxes bellow the datagridview is not changed that i mean  all this time
give me an example code how to  fill  a combox with 2-3 textboxes please
I don't understand why you want that. You have already have that.

I have also provided this code which does exactly what that:
        If Me.ProductIDComboBox.SelectedIndex <> -1 Then

            Dim dr As DataRow = Me.NicolaouDBDataSet.Products.Rows.Find(Me.ProductIDComboBox.SelectedValue)
            If dr IsNot Nothing Then
                'Me.DescriptionTextBox.Text = dr.Item(0).ToString
                Me.DescriptionTextBox.Text = dr.Item("ProductName").ToString
                Me.UnitPriceTextBox.Text = dr.Item("UnitPrice").ToString
                Me.QuantityTextBox.Text = dr.Item("QtyPerUnit").ToString

            End If

        End If

Finally, I can tell that whatever I provide you won't be good! It seems that everything I have provided is not. I never spend so much time on a single question.
Yea  can u  explain me why the  suplierid combobox and the textboxes is working the relation  between the Supplieridcombobox and the product id combobox is working fantastic BUT the textboxes that  belong to Product id is not changed even  i have add this code you   give ABOVE

can u  understand me ?
to Product id combobox  is not changed even  i have add this code you   give ABOVE
you cannot bind the textboxes to the dataset. you would need to bind them to the relations. beleive me it is a lot easier to manually feed them (like the code just pasted).

>>to Product id combobox  is not changed even  i have add this code you   give ABOVE

In the last code you sent me, the SelectedIndexChanged event was not handled. I have already provided that code.
These is  is the form  after i try to explain  u  i wish to understand me
untitled.PNG
can u explain me how i  bind it manually?
oups ok  sorry  how to   to bind them to the relations what you mean  with that.Itry it manually  with the code  you  give me before but is not work the textboxes  belong to product id combobox
you don't want to bind manually, you would have the same problem.

you better assign the values manually in the SelectedIndexChange event.
you better assign the values manually in the SelectedIndexChange event

these code is what i must used?

      If Me.ProductIDComboBox.SelectedIndex <> -1 Then

            Dim dr As DataRow = Me.NicolaouDBDataSet.Products.Rows.Find(Me.ProductIDComboBox.SelectedValue)
            If dr IsNot Nothing Then
                'Me.DescriptionTextBox.Text = dr.Item(0).ToString
                Me.DescriptionTextBox.Text = dr.Item("ProductName").ToString
                Me.UnitPriceTextBox.Text = dr.Item("UnitPrice").ToString
                Me.QuantityTextBox.Text = dr.Item("QtyPerUnit").ToString

            End If

        End If
Finally  i  am  understand what happened:)

 Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
 Private Sub ComboBox2_SelectedIndexChanged

When  i  choose  from the combobox 2 that appear the product  belong to suplier if i choose it the textboxes changed and is working 100%

Apologize and thnks for Help :)