Change field format with VBA

  • Thread starter Thread starter Rudy
  • Start date Start date
R

Rudy

How can I change the value of the Format property
of a Currency field in a table, let say in
"#.##0,00; -#.##0,00", using VBA code?

Using:

Set dbsMyDatabase = CurrentDb
Set dbsMyDatabase.TableDefs("tblAccounts"). _
Fields("Amount"). _
CreateProperty("Format", Text, Null) = _
"#.##0,00;-#.##0,00"

doesn't work.
Neighter does:

Set dbsMyDatabase = CurrentDb
Set dbsMyDatabase.TableDefs("tblAccounts"). _
Fields("Amount"). _
Properties("Format").Value = _
"#.##0,00;-#.##0,00"
 
You need to create the Property separately and then *Append* the Property to
the Properties Collection of the Field Object.

Check the examples in Access Help topic "CreateProperty Method".
 
Van,

it works by creating the property separately and then
adding it to the Properties Collection of the Field Object.

Thanks,

R.W.
 

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

Back
Top