Hello and thank you for viewing my post! I am new to this Forum. Any help with problem is much appreciated.
Database Requirement: Automat the creation of a Table in Access with VB and setting a dbSingle type field's "Format" property to "000.0" as if a user was in the design mode and just typed "000.0" in the "Format" field property value textbox.
It is already understood that the best practice is to not format values in a table. However, the person i'm making the database for is insisting that when a user enters a single digit in the table that it displays as 002.0 and not 2 (Can't get around this...I've tried)
I've tried setting the format property of Field 2 by using the following code.
Private Sub Command1_Click()
Dim dbs As Database, tbl As TableDef, fld As Field, prop As Property
Set dbs = CurrentDb
'--Table Create
Set tbl = dbs.CreateTableDef(Me.Text4)
'--Field 1
Set fld = tbl.CreateField("Vessel Name", dbText)
tbl.Fields.Append fld
'--Field 2
Set fld = tbl.CreateField("Vessel ID", dbSingle)
tbl.Fields.Append fld
prop = fld.CreateProperty("Format", dbSingle, "000.0")
prop.Value = "000.0"
fld.Properties.Append prop
'--Table Refresh
dbs.TableDefs.Append tbl
dbs.TableDefs.Refresh
dbs.TableDefs.Refresh
Application.RefreshDatabaseWindow
End Sub
The highlighted areas in RED is where I get an error message. Any help on this matter is greatly appreciated. Thank You!