• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 144
  • Last Modified:

VB Input Values to Appropriate Format

              -2 combo boxes  where one is user selected for a category and the other is used for choosing multiple subcategories if the user so chooses.

             -2 text boxes where one is for input of frequency (ie say for example you want to schedule something, like painting a building, every so many years, hence frequency) and the other textbox is cost per subcategory.  I need the cost to match the frequency in a datagrid perhaps because of my db.

 Example:   (assuming category is Building, subcats are paint, re-roof, frequency=every 3 yrs
                   cost of paint = 1500.00  and re-roof is 2000.00)

                              2004                2005              2006             2007                  2008        

             Paint          $1500.00                                                  $1500.00
             Re-Roof      $2000.00                                                  $2000.00

  • 2
1 Solution
Bob LambersonSoftware EngineerCommented:
Set the table structure up something like this....

table name :  Maintenance
    fields :  BuildingID           MaintenanceType          Frequency         Date                      Cost
                1                           Paint                           3                       4/10/2004             1500
                1                           Re-Roof                      3                       4/10/2004              2000
                1                           Paint                           3                      4/10/2007              1500
                1                           Re-Roof                      3                       4/10/2007              2000

This way you won't be adding fields to your table and your queries will be much more managable.
All that is needed then is to open the table in code and add the information from the combo boxes to the recordset. Then if you want to display a grid of the information just use the recordset as the record source.

shanemcfAuthor Commented:
 if my customer table      =       CustomerID (PK)   type=number
          maintenance table =       BuildingID    (PK)   type=number
                                               CustomerID (FK)   type=number

   My i-face is to choose from combo boxes for customer and then category, then subcat...

How do I keep my customerid (pk)  the same as my customerid(fk) ???  There is no prompt for an ID.

Thanks in advance...
Bob LambersonSoftware EngineerCommented:
When you add records to the primary table (PK) add any records to the related table (FK) using the same key for both the PK and the FK.
You can do this in any sequece using the PK in the related table as a FK. If you get to a many to many relationship, you will need to have a seperate table that joins the tables with only the keys in it.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now