Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset File Summary Title after Compact/Repair 1

Status
Not open for further replies.

ReluctantDataGuy

Programmer
May 15, 2003
131
0
0
US
I need to replace the File Summary Information Title after its removed by the compact/repair process in MS Access.

I need to set the Title to "MyAppName 3.52"

I've looked through FSO, etc but its all over my head and I need a quick solution. I'm hoping someone has a bit of code that will accomplish the task.

My idea is to programmatically set the Title each time the database opens.

Thanks in advance for any help.

BobK
 


If I understand your request correctly...

Your will find your answer HERE.

Just use the code with your startup..

Good luck...

[thumbsup]

 
That looked promising, but its for Word and I need the code for Access. I played around a bit but so far haven't found anything equivalent in Access.

Thanks!
BobK
 

ReluctantDataGuy,

Here is a possible option.. Why not just change the Title Bar description. There are two properties you can change. The Title and or the title addition. If you use the title addtion, it will show up surrounded by "< >".

Doing this will allow the users to see the info without having to go to the properties page.

Code:
Dim dbs As DAO.Database
Dim prp As DAO.Property
Dim strTitleAddition As String, strCurrentAppTitle As String, strTry As String
On Error Resume Next
Set dbs = CurrentDb
' This changes the Title ..
strCurrentAppTitle = "YourNewTileDB"
strTitleAddition = ""
' Place your extended Desc. here, for example your Version info
If blnBaseTitleOnly = False Then strTitleAddition = "Folsom Prison Blues"
With dbs.Containers!Databases.Documents!MSysDb
    strTry = .Properties("Title")
    If Err.Number = 3270 Then
       Set prp = .CreateProperty("Title", dbText, strCurrentAppTitle)
       .Properties.Append prp
       Set prp = Nothing
    End If
    .Properties("Title") = strCurrentAppTitle & IIf(Len(strTitleAddition) > 0, "  < " & strTitleAddition & " >", "")
    RefreshTitleBar
End With
dbs.Close
Set dbs = Nothing

Also another suggestion is use create a SENDKEYS command.

Hope this helps...

Let me know....

 


Opppssss...

Sorry use this code.

Code:
Dim dbs As DAO.Database
Dim prp As DAO.Property
Dim strTitleAddition As String, strCurrentAppTitle As String, strTry As String
On Error Resume Next
Set dbs = CurrentDb
' This changes the Title ..
strCurrentAppTitle = "YourNewTitleDB"
strTitleAddition = ""
' Place your extended Desc. here, for example your Version info
If blnBaseTitleOnly = False Then strTitleAddition = "Folsom Prison Blues"
With dbs.Containers!Databases.Documents!MSysDb
    strTry = .Properties("AppTitle")
    If Err.Number = 3270 Then
       Set prp = .CreateProperty("AppTitle", dbText, strCurrentAppTitle)
       .Properties.Append prp
       Set prp = Nothing
    End If
    .Properties("AppTitle") = strCurrentAppTitle & IIf(Len(strTitleAddition) > 0, "  < " & strTitleAddition & " >", "")
    RefreshTitleBar
End With
dbs.Close

Again sorry for the mistake..

 
ReluctantDataGuy,
The summary data is stored in an Alternate Data Stream (ADS) for Access databases. I have no idea how to create the ADS from scratch, but I have stumbled on a way to copy the ADS from another database.

To use this you could create a 'dummy' database (db1.mdb in this example) that exists only to hold the Summary Data that you want to copy to your freshly compacted database.

This was written and tested in Office 2003 and tested only with Access database files.
Code:
[navy]Sub [/navy] CopySummaryStream()
[navy]Dim In[/navy]tFile [navy]As [navy]In[/navy]teger[/navy]
[navy]Dim[/navy] strFile [navy]As String[/navy]
[navy]Dim[/navy] strStreamName [navy]As String[/navy]
[navy]Dim[/navy] strData [navy]As String[/navy]

[green]'Get an unused file number[/green]
intFile = FreeFile

[green]'Set the Stream name[/green]
strStreamName = ":" & Chr(5) & "SummaryInformation"

[green]'Get the Information from the source file[/green]
strFile = "[i]C:\db1.mdb[/i]" & strStreamName
[navy]Open[/navy] strFile [navy]For Binary As[/navy] #intFile
[green]'Initialize the size of the data buffer[/green]
strData = Space(LOF(intFile))
[navy]Get[/navy] #intFile, , strData
[navy]Close[/navy] #intFile

[green]'Write the summary Information To the destination file[/green]
strFile = "[i]C:\YourCompactedDatabase.mdb[/i]" & strStreamName
[navy]Open[/navy] strFile [navy]For Binary As[/navy] #intFile
[navy]Put[/navy] #intFile, , strData
[navy]Close[/navy] #intFile
[navy]End Sub [/navy]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
THANK YOU CAUTIONMP!!!

I didn't want to have to store a dummy database to hold the SummaryInformation so using your example as a starting point, I figured out that I could store the binary string in an OLE Object type field in a table in my database.

The user clicks a button called [Compact Database] - so in the OnClick event for that button, I get the file's SummaryInformation and store it in a table.

I put code in the startup form's OnOpen event that gets the SummaryInformation string from the OLE Object type field in the database, and sets the file's SummaryInformation to that file.

Ideally, I'd like to imporove this technique by storing a SummaryInformation string with a nominal version value - and then set the file's SummaryInformation every time the file opens by replacing the nominal version value with the actual version.

Thanks again!
BobK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top