Accessing Database Tables (Access Database)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tmcdon05
    New Member
    • Feb 2008
    • 2

    Accessing Database Tables (Access Database)

    With VB 2005 - I have a form that has comboboxes for selecting data from tables. User can select a customer name for instance and that is all that is in the combobox and on the form. I Want to take the information from that combobox and display it on another form that will be printed. I have no problem showing the combobox text but what I need is the other info that is related to that combobox to also print. I'll try to explain:
    Table1 - Customer Name & Address info
    Table2 - Item For Sale (Kinda!)
    Table3 - The Actual Sale data (This table references primary keys from the other 2 tables - actually lots more tables involved but 2 is good enough for the example!))
    Form1 - Used to Select customer & item purchased. Form1 only shows the customer name and the item name in the comboboxes (databound).

    I need another form to print the customer's name, address, etc. from Table1 and all of the info from Table2 about the product as well, the printing coming from columns in Table3, that are holding references to the other 2 tables (make sense?!). I know how to have the printing form print the customer name (I can reference the original form's combobox.text property for that, and have) but not how to have it grab the rest of the customer's info from the Customers table (Table1) as well as the priduct info from Table2!
    Example:
    Table1 Columns: cust_name, cust_add1, cust_add2, etc.
    Table2 Columns: veh_stockno, veh_vin, veh_mileage, etc.
    Table3 Columns: deal_cust, deal_veh
    Form1: Comboboxes for choosing Customer & Vehicle
    Form2: Need to Print Form containing Customer Name, Address, etc. & all vehicle information that was chosen on Form1

    I know this is a lot of mumbled info but I always try to give as much info as possible when asking a question. It saves going back and forth! Any help would be appreciated!
    Thanks
  • Baladin
    New Member
    • Feb 2008
    • 14

    #2
    So basically you want it so when you select an item from a combo box on one form it will display the data from the table onto another form?

    If that is the case you need a Module and on that Module declare a Public Variable
    ie.
    Public Customer As string

    Then in your form with the Combo box make the Public variable equal the combo box
    Customer = ComboBox.Text

    Then on your other form search the table for row that contains the data item Customer

    Use the row number you get from that to display the rest, hope that helped

    Comment

    • tmcdon05
      New Member
      • Feb 2008
      • 2

      #3
      DUH!! As soon as I read your reply - it was painfully clear! Thanks for the response!
      Tony

      Comment

      Working...