Another thing to do is turn off NameAutocorrect.
If you leave it on, you can get sub data sheets created automatically
when
you create a new table.
NameAutoCorrect is set from Access options. In A2003 it is on the
General
tab.
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
message
Here's the code:
Public Sub KillSubDataSheets()
' © Arvin Meyer 6/25/2005
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim prp As DAO.Property
Dim i As Integer
Const conNone = "[None]"
Const conProp = "SubDataSheetname"
Set db = CurrentDb()
SysCmd acSysCmdInitMeter, "Deleting SubDataSheets ...",
db.TableDefs.Count
For i = 0 To db.TableDefs.Count - 1
Set tdf = db.TableDefs(i)
If Mid(tdf.Name, 2, 3) <> "sys" Then
If tablePropExist(conProp, tdf) Then
tdf.Properties(conProp) = conNone
Else
Set prp = tdf.CreateProperty(conProp, dbText, conNone)
tdf.Properties.Append prp
Set prp = Nothing
End If
End If
SysCmd acSysCmdUpdateMeter, i
Next i
SysCmd acSysCmdRemoveMeter
Set tdf = Nothing
Set prp = Nothing
MsgBox "Done!"
End Sub
Private Function tablePropExist(ByVal thePropName As String, ByRef
theTD
As DAO.TableDef) As Boolean
'© Arvin Meyer 6/25/2005
' PURPOSE: To determine if a property exists in a tabldef
' ACCEPTS: - Name of property we are checking on
' - Pointer to tabledef in question
' RETURNS: True if property exists, else False
Dim prp As DAO.Property
On Error Resume Next
Set prp = theTD.Properties(thePropName)
On Error GoTo 0
If Not prp Is Nothing Then
tablePropExist = True
End If
End Function
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Setting subdatasheets will slow the database tremendously. I use code
to
make sure that all of them are always set to [none].
Unless you have a single user database, the tables should never bein
sight
or used by the database users. Doing so jeopardizes data integrity..
--
Arvin Meyer, MCP,
MVPhttp://
www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmv...
I tried to set subdatasheet property at table design view.
After I set the property on the backend which works, but it changes
back to auto when I reopen it.
Even backend subdatasheet name work at backend. It seems frontend
does
not know the datasubsheet property and I can not set in the front
end.
Any information can set subdatasheetname property at run time or
makes
it work in the front end is great appreciated,- Hide quoted text-
- Show quoted text -
I set them to none, but it changes to Auto.
Can you please let me know any how to set to none using VBA code?
Thanks again,- Hide quoted text -
- Show quoted text -