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.
 
Back
Top