Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[blue]Public Sub SetDefault([purple][b]tblName[/b][/purple] As String, [purple][b]fldName[/b][/purple] As String, [purple][b]DefVal[/b][/purple])
Dim dbs As Object, db As DAO.Database
Dim fld As Field, Prp As Property, Typ As Integer
Dim Msg As String, Style As Integer, Title As String, DL As String
Set dbs = Application.CurrentData
DL = vbNewLine & vbNewLine
If dbs.AllTables(tblName).IsLoaded Then
Msg = "Default can't be set at this time!" & DL & _
"Table '" & tblName & "' is in use!" & DL & _
"Close the table & try again . . ."
Style = vbInformation + vbOKOnly
Title = "Can't Set Default! . . ."
MsgBox Msg, Style, Title
Else
Set db = CurrentDb()
Set fld = db.TableDefs(tblName).Fields(fldName)
Set Prp = fld.Properties("DefaultValue")
Typ = fld.Type
If Len(Trim(DefVal) & "") > 0 Then
If Typ = dbText Then 'Text
Prp = """" & DefVal & """"
ElseIf Typ = dbDate Then 'Date/Time
Prp = "#" & DefVal & "#"
Else
Prp = Val(DefVal) 'Numeric
End If
Else
Prp = "" 'No Data
End If
Set Prp = Nothing
Set fld = Nothing
Set db = Nothing
End If
Set dbs = Nothing
End Sub[/blue]
[purple]This makes changing Table Defaults impractical . . . .[/purple]number2 said:[blue]It could be installed peer to peer. The db is split.[/blue]