Results 1 to 1 of 1
  1. #1
    Join Date
    Jul 2012

    Unanswered: Logically associating values with their units of measure

    I am trying to create a database in Access 2003 to generate a large ini file for an application. Many of the sections are clean and easy to do, and up to this point the VB part is fine. A database is (I think) the right tool for the job because there are a lot of relationships that need to be enforced between different sections. Maybe this indicates that the ini file is badly designed, but it is what it is!

    However, I am scratching my head over several sections that need both a value and a unit. For example, here are a few sections relating to fluid properties:

    ObjectType = Param
    DataType = string
    Value = Water

    ObjectType = Param
    DataType = double
    Value = 288.15
    Unit = K

    ObjectType = Param
    DataType = double
    Value = 10.5E5
    Unit = Pa

    ObjectType = Param
    DataType = double
    Value = 999.10
    Unit = kg/m3

    So the table is called Fluid, the records have a (key) identifier field that goes 1 .. n and the field names are, for example, Ref:rho (because the dot upsets Access). The export VBA code concatenates this lot, replaces colons with dots, and makes section headers like [Fluid.1.Ref.rho]. DataType comes from the field properties with a little mangling because the types do not look exactly like Access, which is fine as the data type of each parameter is fixed (though they are not all doubles). Value comes from the field itself, obviously. So far so good - it is easy to create a new product by adding a record, and each field can have the right type, validation rule and so on.

    The trouble is Unit. Each field needs an associated unit, which may change from one configuration to another but will be consistent across all records. Having tried and failed to come up with a way of sneaking units into field properties of the Fluid table, my only idea at the moment is to create another table called something like Fluid_units. It could have the same field names as the Fluid table and one record, or perhaps it might be better to have one record in Fluid_units per field name in Fluid. Either way, the VB can glue them together for output. But it is hideously inelegant, and it would be tedious to put the units on a form alongside the values (all I can think of at the moment is an On Open VB to put the units into some text boxes).

    Please can anybody suggest a way to put this together nicely, so the units are properly associated with the values at a database level??
    Last edited by LostTrolley; 07-26-12 at 09:48.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts