Urgent 1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shailja
    New Member
    • Feb 2007
    • 123

    #1

    Urgent 1

    Hello,

    My Front End is VB and Back End is Access.
    I have two tables in my Database. One is Company table other is Branch table. Company contains ComID as primary key and ComName fields. Branch contains ComID as foreign key.

    I have combobox on my form. Combobox should display company names but when i select company name from combox , ID of that company should be stored in Branch table. It means Display field is company name and value field is comID.

    how to do coding of this in Visual Basic. Plz tell me.

    Thanks
  • samycbe
    New Member
    • Feb 2007
    • 83

    #2
    Dear Friend,

    1. Just select the company names and display it in combo box.
    2. Have one invisible textbox named txtinvcompid
    3.on combo box click or change event write the code like
    select compid from company where compname =' " & cbocomp & " ' "
    4. store that value to the invisble text box


    is it ok?

    samy

    Comment

    • vijaydiwakar
      Contributor
      • Feb 2007
      • 579

      #3
      Originally posted by Shailja
      Hello,

      My Front End is VB and Back End is Access.
      I have two tables in my Database. One is Company table other is Branch table. Company contains ComID as primary key and ComName fields. Branch contains ComID as foreign key.

      I have combobox on my form. Combobox should display company names but when i select company name from combox , ID of that company should be stored in Branch table. It means Display field is company name and value field is comID.

      how to do coding of this in Visual Basic. Plz tell me.

      Thanks

      u have to use combobox's itemdata to store the id
      its combobox's hidden property

      Comment

      • Shailja
        New Member
        • Feb 2007
        • 123

        #4
        Originally posted by samycbe
        Dear Friend,

        1. Just select the company names and display it in combo box.
        2. Have one invisible textbox named txtinvcompid
        3.on combo box click or change event write the code like
        select compid from company where compname =' " & cbocomp & " ' "
        4. store that value to the invisble text box


        is it ok?

        samy

        No, I want complete coding.

        Comment

        • samycbe
          New Member
          • Feb 2007
          • 83

          #5
          on form load......

          1. create combobox named cbocomp
          2. create text box txtinvcomp

          cbocomp.clear
          sql = " select compname from company order by compname"
          rs.open,sql,con str
          do while not rs.eof
          cbocomp.additem rs!compname
          rs.movenext
          loop

          on cbocomp_click
          sql = " select compid from company where compname =' " & cbocomp &" ' "
          rs.open sql,constr
          if not rs.eof then
          txtinvcomp = rs!compid
          end if

          still not clear call me 91 9944099800 or mail me
          v.arumugasamy@s aipem-india.com i will send file

          samy

          Comment

          • Shailja
            New Member
            • Feb 2007
            • 123

            #6
            Originally posted by samycbe
            on form load......

            1. create combobox named cbocomp
            2. create text box txtinvcomp

            cbocomp.clear
            sql = " select compname from company order by compname"
            rs.open,sql,con str
            do while not rs.eof
            cbocomp.additem rs!compname
            rs.movenext
            loop

            on cbocomp_click
            sql = " select compid from company where compname =' " & cbocomp &" ' "
            rs.open sql,constr
            if not rs.eof then
            txtinvcomp = rs!compid
            end if

            still not clear call me 91 9944099800 or mail me
            v.arumugasamy@s aipem-india.com i will send file

            samy
            Got it. Thanks a lot

            Comment

            Working...