Module and Macro

Teknologik

New member
Local time
Today, 11:04
Joined
Feb 10, 2011
Messages
7
Hello,

I have created a Module which is used to amend the data type of a table from a number to Text 30.

This is the code used.

Public Sub ChangeDataType()

Dim dbase As DAO.Database

Set dbase = CurrentDb

dbase.Execute ("ALTER TABLE [FM 1 Cref Make] ALTER COLUMN [CALL_IN_REF] text(30);")

End Sub

This module works perfectly fine when run manually but when it is in a Macro
as a RunCode the following error message appears when the Macro is run.

Error

The expression you entered has a function name that MS Office Access can't find

Even though in the macro the name of the ChangeDataType()

Any help much appreciated.

Thanks
 
How is your code invoked?
The clue may be in the error message - it says "can't find the function ..." but you have a sub?
You can simplify your code like this (whether Function or Sub):
Code:
Public Function ChangeDataType()
CurrentDb.Execute ("ALTER TABLE [FM 1 Cref Make] ALTER COLUMN [CALL_IN_REF] text(30);")
End Function
 

Users who are viewing this thread

Back
Top Bottom