Go Back   Access World Forums > Apps and Windows > VB.NET

 
Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 12-29-2013, 06:35 PM   #1
Ajit Singh
Newly Registered User
 
Join Date: Jul 2013
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Ajit Singh is on a distinguished road
Application Title bar for each accdr file.

Am using below code to create accdr files with filename as cost center number. Now I need to have filename i.e. cost center number at the application title bar of each accdr file.

Please help
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dim appAccess As New Access.Application
sLocalPath = "h:\Global\Programs-Global\Cost Center Reporting Tool\Testing\Template.accdb"
sLocalsPath = "h:\Global\Programs-Global\Cost Center Reporting Tool\Testing\Output\" & Me.Combo8 & ".accdr"
With appAccess
.AutomationSecurity = 1 'MsoAutomationSecurityLow
.UserControl = True
.SysCmd 603, sLocalPath, sLocalsPath

End With
.MoveNext
Loop
.Close
End With

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Ajit Singh is offline   Reply With Quote
Old 12-29-2013, 10:34 PM   #2
Mihail
Newly Registered User
 
Join Date: Jan 2011
Location: Romania
Posts: 2,373
Thanks: 90
Thanked 367 Times in 362 Posts
Mihail is on a distinguished road
Re: Application Title bar for each accdr file.

Code:
Private Sub Combo8_Click()
Dim sLocalPath As String
Dim sLocalsPath As String
Dim appAccess As New Access.Application
    sLocalPath = "h:\Global\Programs-Global\Cost Center Reporting Tool\Testing\Template.accdb"
'    sLocalPath = "C:\Documents and Settings\Camelia\Desktop\Access\Teste\WelFare\Welfare.mdb"

    sLocalsPath = "h:\Global\Programs-Global\Cost Center Reporting Tool\Testing\Output\" & Me.Combo8 & ".accdr"
'    sLocalsPath = "C:\Documents and Settings\Camelia\Desktop\Access\Teste\WelFare\" & Me.Combo8 & ".accdr"

Dim strActualTitle As String, strNewTitle As String
    Dim proTitle As Property

    With OpenDatabase(Name:=sLocalPath)
        'store actual title of the .mdb (.accdb)
        strActualTitle = .Name
        
        'Create new title
        strNewTitle = Me.Combo8
        
        'Change the title
        Set proTitle = .CreateProperty("AppTitle", dbText, strNewTitle)
        Call .Properties.Append(proTitle)
        .Properties("AppTitle").Value = strNewTitle
        
        'close the DB
        Call .Close
    End With
    
    'Create .accdr
    With appAccess
        .AutomationSecurity = 1 'MsoAutomationSecurityLow
        .UserControl = True
        .SysCmd 603, sLocalPath, sLocalsPath
    End With
    
    'Restore the old title for the .mdb (.accdb)
    With OpenDatabase(Name:=sLocalPath)
        Set proTitle = .CreateProperty("AppTitle", dbText, strActualTitle)
        .Properties("AppTitle").Value = strActualTitle
        
        'close the DB
        Call .Close
    End With
End Sub
__________________
Mihail
I'm looking for a job !
Very good technical skills on Metal Sheets:
Design (SolidWorks), Programming/Operating machines (Cutting, Bending, Punching)
Mazatrol for turning machines
Mihail is offline   Reply With Quote
Old 12-30-2013, 01:02 AM   #3
Ajit Singh
Newly Registered User
 
Join Date: Jul 2013
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Ajit Singh is on a distinguished road
Re: Application Title bar for each accdr file.

Thank you for the instant reply......


am encountering an error on line code "Call .Properties.Append(proTitle)" at the time to preparing the second file.

"Run time error 3367.....Cannot append. An object with that name already exists in the collection."

Please help

Ajit Singh is offline   Reply With Quote
Old 12-30-2013, 03:36 AM   #4
Mihail
Newly Registered User
 
Join Date: Jan 2011
Location: Romania
Posts: 2,373
Thanks: 90
Thanked 367 Times in 362 Posts
Mihail is on a distinguished road
Re: Application Title bar for each accdr file.

Code:
Private Sub Combo8_Click()
On Error GoTo ErrorHandler

Dim sLocalPath As String
Dim sLocalsPath As String
Dim appAccess As New Access.Application
'    sLocalPath = "h:\Global\Programs-Global\Cost Center Reporting Tool\Testing\Template.accdb"
    sLocalPath = "C:\Documents and Settings\Camelia\Desktop\Access\Teste\WelFare\Welfare.mdb"

'    sLocalsPath = "h:\Global\Programs-Global\Cost Center Reporting Tool\Testing\Output\" & Me.Combo8 & ".accdr"
    sLocalsPath = "C:\Documents and Settings\Camelia\Desktop\Access\Teste\WelFare\" & Me.Combo8 & ".accdr"

Dim strActualTitle As String, strNewTitle As String
    Dim proTitle As Property

    With OpenDatabase(Name:=sLocalPath)
        'store actual title of the .mdb (.accdb)
        strActualTitle = .Name
        
        'Create new title
        strNewTitle = Me.Combo8
        
        'Change the title
        Set proTitle = .CreateProperty("AppTitle", dbText, strNewTitle)
        Call .Properties.Append(proTitle)
        .Properties("AppTitle").Value = strNewTitle
        
        'close the DB
        Call .Close
    End With
    
    'Create .accdr
    With appAccess
        .AutomationSecurity = 1 'MsoAutomationSecurityLow
        .UserControl = True
        .SysCmd 603, sLocalPath, sLocalsPath
    End With
    
    'Restore the old title for the .mdb (.accdb)
    With OpenDatabase(Name:=sLocalPath)
        Set proTitle = .CreateProperty("AppTitle", dbText, strActualTitle)
        .Properties("AppTitle").Value = strActualTitle
        
        'close the DB
        Call .Close
    End With

Ex:

Exit Sub

ErrorHandler:
    Select Case Err.Number
        Case 3367
            Resume Next
        Case Else
            MsgBox (Err.Number & ": " & Err.Description)
            Resume Ex
    End Select
End Sub
__________________
Mihail
I'm looking for a job !
Very good technical skills on Metal Sheets:
Design (SolidWorks), Programming/Operating machines (Cutting, Bending, Punching)
Mazatrol for turning machines
Mihail is offline   Reply With Quote
Old 12-30-2013, 03:37 AM   #5
Mihail
Newly Registered User
 
Join Date: Jan 2011
Location: Romania
Posts: 2,373
Thanks: 90
Thanked 367 Times in 362 Posts
Mihail is on a distinguished road
Re: Application Title bar for each accdr file.

Change the Paths to yours
__________________
Mihail
I'm looking for a job !
Very good technical skills on Metal Sheets:
Design (SolidWorks), Programming/Operating machines (Cutting, Bending, Punching)
Mazatrol for turning machines
Mihail is offline   Reply With Quote
Old 12-30-2013, 04:01 AM   #6
Mihail
Newly Registered User
 
Join Date: Jan 2011
Location: Romania
Posts: 2,373
Thanks: 90
Thanked 367 Times in 362 Posts
Mihail is on a distinguished road
Re: Application Title bar for each accdr file.

Note please that this is an "instant" solution.
A true solution is to remove the property from the DB, but I can't do my best now, one day before the new year, because I have drink some "PALINKA", a Romanian drink that is, in my opinion, better than any whisky I ever drink.
So, my friend, take a break until the new year will come, and will see.

Happy New Year
and All the Best
__________________
Mihail
I'm looking for a job !
Very good technical skills on Metal Sheets:
Design (SolidWorks), Programming/Operating machines (Cutting, Bending, Punching)
Mazatrol for turning machines
Mihail is offline   Reply With Quote
Old 12-30-2013, 07:01 PM   #7
Ajit Singh
Newly Registered User
 
Join Date: Jul 2013
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Ajit Singh is on a distinguished road
Re: Application Title bar for each accdr file.

It worked as a wonder !!!!!!!!!!

Thank you so much and enjoy your drink.

Wish you a very happy new year to you and to your family.

Thanks


Ajit Singh is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem opening an .accdr file Robert McWhorter General 1 11-08-2012 03:34 PM
Question Package solution missing the most important file: my .accdr file merika General 3 09-11-2012 06:33 AM
importing dbf to accdr file dfishfan Modules & VBA 1 09-01-2011 12:25 AM
change application title qwertyjjj Modules & VBA 3 11-23-2006 03:14 PM
Application Title Bar theprez General 5 12-21-2003 07:31 PM




All times are GMT -8. The time now is 09:38 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World