Use table in VB subroutine that is not part of form

  • Thread starter Thread starter Randy Hartwick
  • Start date Start date
R

Randy Hartwick

I have a form that contains a reference to a VB procedure
to perform a calculation. Most of the data needed for the
calculation is entered in the form. I have two values
(mileage rate and hourly rate) that are not a part of the
form, but are part of the calculation performed in the VB
subroutine. I currently have them hard coded into the
subroutine. I would like to be able to put them in a
table, but I cannot determine how to reference the table
in the VB subroutine if it is not linked in some manner to
the form.

The mileage rate and hourly rate are only used in the
calculation and are not a part of any other table nor do
they have any relation to any table. I would prefer these
fields not be displayed on the form.

Thanks for any help.
 
Randy,

Have you considered using DLookUp() to retrieve your mileage and hourly rate
values from a table?
 
This is a common problem that I have solved by using a special table
tblGlobal in just about every project I do. This table ALWAYS has just one
row of data and as many fields as I need to bring the project to completion.
In your case the table will have 3 fields GlobalID, MileageRate, and
HourlyRate. Global ID is a Autonumber and is the Primary Key, and the other
2 fields would likely be Currency types. Whenever you need a value you can
grab it with a DLookup() call. for instance to get the MileageRate you
might do something like this:

curMileageRate = NZ(DLookup("MileageRate","tblGlobal","GlobalID=1"),0)

Ron W
 
Back
Top