Changing a Table Field Type

Bullman2000_uk

Registered User.
Local time
Tomorrow, 03:09
Joined
Jun 6, 2007
Messages
17
I have a field in a table that is imported from another database, its type is Test but I need to set it as a number field during a VB calculation Macro. Can you please advise how I do this?



Thanks
 
Is the field you are importing it into a numeric field?
 
Its an already created table but the database that was designed required it to be a number. I have been changing it manually every week but I need to automate it incase I am out of the office as no-one else can change it
 
Can you not wrap either Val() or CInt(), CDbl() or CLng() around the text type field data in your calculations?
 
I think my best bet is if there is anyway in VB to change the field type before I begin my calculation queries that merge 2 tables together and add a vast amount of information
 
Try this:

Create a button to your form and put this code:

Dim strSQL
strSQL = "ALTER TABLE tblYOURTABLE ALTER COLUMN txtYOURCOLUMN NUMBER"
CurrentDb.Execute strSQL, dbFailOnError
MsgBox "Column change to number", vbInformation, "your db"
 

Users who are viewing this thread

Back
Top Bottom