Darren DICK
d.dick at uws.edu.au
Mon Nov 22 16:57:24 CST 2004
Howdy
Create a Button on a form and call the button Command0 - form name is not
important
Copy everything below the line and paste it into the code behind the form
Make sure you have a DAO reference
Hope this helps
Darren
____________________________________________________________________
Private Sub Command0_Click()
TurnOffSubDataSheets
End Sub
Function TurnOffSubDataSheets()
Dim MyDB As DAO.Database
Dim MyProperty As DAO.Property
Dim propName As String
Dim PropType As Integer
Dim propVal As String
Dim strS As String
Set MyDB = CurrentDb
propName = "SubDataSheetName"
PropType = 10
propVal = "[NONE]"
On Error Resume Next
For i = 0 To MyDB.TableDefs.Count - 1
If (MyDB.TableDefs(i).Attributes And dbSystemObject) = 0 Then
If MyDB.TableDefs(i).Properties(propName).Value <> propVal Then
MyDB.TableDefs(i).Properties(propName).Value = propVal
intChangedTables = intChangedTables + 1
End If
If Err.Number = 3270 Then
Set MyProperty = MyDB.TableDefs(i).CreateProperty(propName)
MyProperty.Type = PropType
MyProperty.Value = propVal
MyDB.TableDefs(i).Properties.Append MyProperty
Else
If Err.Number <> 0 Then
MsgBox "Error: " & Err.Number & " on Table " _
& MyDB.TableDefs(i).Name & "."
MyDB.Close
Exit Function
End If
End If
End If
Next i
MsgBox "The " & propName & _
" value for all non-system tables has been updated to " & propVal & "."
MyDB.Close
End Function