Define attributes of fields when creating a table in VBA

G

Gilbert 2097

Hi all you smart people!!! Using Acc03 I'm creating tables using something
like dbs.tdf.fields creatfield("MyField") and everything is working fine.
Tables are created and working good. I learned how to set fld = "MyField"
and to set the attribute of AutoNumber and that workd great. But I can't
see how to set the format of a field. I can set the DefaultValue like
fld.DefaultValue=17 but when I tried fld.Format "Medium Time" it didn't
recognize the property 'Format'. Can someone put me on the right track as
to how to format a field in a table using this method??
 
A

Allen Browne

See:
http://allenbrowne.com/func-DAO.html#CreateTableDAO

The Format() property doesn't exist if it has never been created. Therefore
you need to CreateProperty() and set it. What I personally do is use a
function named SetPropertyDAO() that creates the property if needed, and
sets it. It's on the same page:
http://allenbrowne.com/func-DAO.html#SetPropertyDAO
and there is an example to set the Format property to Currency in the
StandardProperties() function, like this:
Call SetPropertyDAO(fld, "Format", dbText, "Currency", strErrMsg)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top