code for changing field datatype (1 Viewer)

lipin

Registered User.
Local time
Today, 13:04
Joined
May 21, 2002
Messages
149
I have a table that is made from a query. It gives an ID# and Hours worked. When the table is made, the numeric datatype for Hours worked is double, decimal = auto.

Well. I have other queries that run off this table and they don't seem to work correctly unless the I change the datatype to INT and the decimal places to 0. All these queries are run consecutively in a macro. So to get the correct final results I need to code in a step to change the field to Int and decimal to 0.
But coding sure isn't a strength of mine; so could someone please tell me how to code the changes.

Thank you very much.
Lipin
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:04
Joined
Feb 28, 2001
Messages
26,996
Don't try to do this as you described it.

Instead, write a query that exactly mimics the source table. But in the column where you call out the double, use CInt(field-name) in its place. Or CLng if you need long integers.

Warning: This query's field name can't exactly match the name of the underlying table's corresponding field.

Once you build the query that you need, base all other things that need the integer on the query. Things that can use the double can stay pointed to the table.

Alternative: If the things that need the integer are relatively few in number, just change THEM to use CInt(field-name) in place of the raw field value.
 

Users who are viewing this thread

Top Bottom