You could have mentioned that originally. Not a big thing to modify. Try
this instead
'---------------------------------------------------------------------------------------
' Procedure : SwitchFieldType
' Author : CARDA Consultants Inc.
' Website :
http://www.cardaconsultants.com
' Purpose : Switch a given table field to Memo
' Copyright : The following may be altered and reused as you wish so long as
the
' copyright notice is left unchanged (including Author, Website
and
' Copyright). It may not be sold/resold or reposted on other
sites (links
' back to this site are allowed).
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' sDb - Database Path & Name to execute command against
' sTableName - Name of the Table which has the field to switch
' sFieldName - Name of the field to switch to Memo Type
'
' Usage:
' ~~~~~~~~~~~~~~~~
' SwitchFieldType("D:\Contacts\Contacts.mdb","tbl_Contact","Notes")
'
' Revision History:
' Rev Date(yyyy/mm/dd) Description
'
**************************************************************************************
' 1 2009-Mar-13 Initial Releas
'---------------------------------------------------------------------------------------
Function SwitchFieldType(sDb As String, sTableName As String, sFieldName As
String)
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim sSQL As String
''Execute the query statement under DAO like this:
'DBEngine(0)(0).Execute sSQL, dbFailOnError
''or under ADO like this:
'CurrentProject.Connection.Execute sSQL
Set db = DBEngine.Workspaces(0).OpenDatabase(sDb)
sSQL = "ALTER TABLE " & sTableName & " ALTER COLUMN " & sFieldName & "
MEMO;"
DoCmd.SetWarnings False
db.Execute sSQL, dbFailOnError
DoCmd.SetWarnings True
Set db = Nothing
If Err.Number = 0 Then Exit Function
Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
Err.Number & vbCrLf & "Error Source: SwitchFieldType" & vbCrLf & "Error
Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Exit Function
End Function
--
Hope this helps,
Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples:
http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.