此代码尚未经过彻底测试,但它可能对您有所帮助。在尝试之前备份您的数据库。
它的目的是用通用 value 替换 Access (偷偷地)存储的硬编码Format
属性。$#,##0.00;($#,##0.00)
Currency
Sub TweakCurrencyFormats()
Dim cdb As DAO.Database, tbd As DAO.TableDef, fld As DAO.Field
Dim ao As AccessObject, frm As Form, ctl As Control
Set cdb = CurrentDb
Debug.Print "Processing tables..."
For Each tbd In cdb.TableDefs
For Each fld In tbd.Fields
If fld.Type = 5 Then '' Currency
Debug.Print "[" & tbd.Name & "].[" & fld.Name & "]"
fld.Properties("Format").Value = "Currency"
fld.Properties("CurrencyLCID").Value = 1053 '' Swedish
End If
Next
Set fld = Nothing
Next
Set tbd = Nothing
Debug.Print "Processing forms..."
For Each ao In CurrentProject.AllForms
If Not ao.IsLoaded Then
DoCmd.OpenForm ao.Name, acDesign
End If
Set frm = Application.Forms(ao.Name)
For Each ctl In frm.Controls
If ctl.Properties("ControlType").Value = 109 Then '' text box
If Left(ctl.Properties("Format").Value, 1) = "$" Then
Debug.Print "[" & ao.Name & "].[" & ctl.Name & "]"
ctl.Properties("Format").Value = "Currency"
End If
End If
Next
Set ctl = Nothing
Set frm = Nothing
Next
Set ao = Nothing
Set cdb = Nothing
End Sub