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!

hello friends. I need some code.

Status
Not open for further replies.

ajayas

Programmer
Sep 22, 2001
20
0
0
IN
hello friends.
I need some code.
I work with VB6 (ADO) and MS Access-2000 .
I have created a dsn (XYZ) for my database using ms access driver.
My database changes every financial year.
(eg. current database in dsn (XYZ) is c:\data\2002.mdb.
next year it will be c:\data\2003.mdb and so on.)
So if i work in year 2002 i want to create a dsn for year 2003 and set my current dsn (XYZ) path to c:\data\2003.mdb
So whenever i want i can shift to any of the year and work on that database.
It will be good if i get a code for ADO rather then DAO.
Thanks in advance.
 
I have a photo database that stores the Path in a field that allows me to move the database around. I don't know if this is what you need but it may be worth a try.

The following code allows you to browse to a Folder

Option Compare Database

'************** Code Start **************
'This code was originally written by Terry Kreft.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code courtesy of
'Terry Kreft

Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long

Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
As Long

Private Const BIF_RETURNONLYFSDIRS = &H1
Public Function BrowseFolder(szDialogTitle As String) As String
Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer

With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
End With

dwIList = SHBrowseForFolder(bi)
szPath = Space$(512)
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)

If X Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Else
BrowseFolder = ""
End If
End Function

'*********** Code End *****************

The next bit calls it from a form in my case


Dim strFolderName As String
strFolderName = BrowseFolder("What Folder you want to select?")
Me![RootFolder] = strFolderName & "\"

Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top