Microsoft
Software
Hardware
Network
Question : change size of text field via DAO
I want to change the size of a text field in an MS Access database programatically (via DAO ver. 4). I have code for changing the field name which worked so I modified it to change the size. Here it is. The code runs, no errors BUT the field size is still the same afterwards.
Have I misunderstood the put_Size purpose?
Can I do it this way?
(A method which would work and which I could code would be to change the field name, create new field, copy contents, then delete original field - so please don't suggest that route)
void ChangeFieldTextSize(CDaoDa
tabase* pDB, LPCTSTR pszTblName, LPCTSTR pszFieldName, long lSize)
{
CDaoTableDef tbl(pDB);
tbl.Open(pszTblName);
DAOField* pField = NULL;
DAOFields* pFields = NULL;
TRY {
tbl.m_pDAOTableDef->get_Fi
elds(&pFie
lds);
COleVariant vName(pszFieldName,VT_BSTR
T);
pFields->get_Item(vName, &pField);
pField->put_Size((long)lSi
ze);
}
CATCH_ALL(e)
{
//Clean up before we re-throw the exception
tbl.Close();
if (pFields != NULL)
pFields->Release();
if (pFields != NULL)
pFields->Release();
//Re-throw the exception so that the caller can catch it or let MFC catch it.
THROW_LAST();
}
END_CATCH_ALL
Answer : change size of text field via DAO
if your database is set to use the ANSI SQL-92 Extensions (In MS Access, Tools --> Options --> Tables/Queries, see the bottom right frame) you can use DDL
ALTER TABLE myTable ALTER myColumn datatype, size
as for using DAO ... from the help file for DAO Field.Size property ...
... For an object not yet appended to the Fields collection ...
so once it is a part of the table it cannot be changed with DAO.
and I suspect the same thing for .DefinedSize proerty of a Column object in ADOX.
Steve
Random Solutions
Can i promote w2003 member sever with exchange 2007 to domain controller
DoCmd.TransferText acExportDelim, "", "qryStockExport", file, False, "" not working in an adp
Datagrid selection change on mouseove
Cant Change dbo login
Windows Update returns Error 403 forbidden
Access database form check box
Global Error Handling - winform
how to get MS Access query "description" text field via VBA
DHCP WINS scope options
visual studio addin deploy for 2005 and 2008