473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Find Extension of current database

Dear Sirs/Madams,

Let me ask you a question about a Visual Basic Code in Access 2007.

I try to do a simple thing (as I believe) but I do not know how.
I want a code that will check the extension of the current Access 2007 Database file and give a spesific msg.

For example, I need a code that will find the path of the running database
ex: "C:\test.accdb" and will check the following:

If the file path is *.accdb then Msgbox "The file extension is accdb"
If the file path is *.accde then Msgbox "The file extension is accde"

How can I do that ?
If u know to do this in access 2003 or older versions just tell it to me pls and I will try it to 2007.
Thanks in advnaced.
Dec 1 '07 #1
6 4871
Dököll
2,364 Expert 2GB
Dear Sirs/Madams,

Let me ask you a question about a Visual Basic Code in Access 2007.

I try to do a simple thing (as I believe) but I do not know how.
I want a code that will check the extension of the current Access 2007 Database file and give a spesific msg.

For example, I need a code that will find the path of the running database
ex: "C:\test.accdb" and will check the following:

If the file path is *.accdb then Msgbox "The file extension is accdb"
If the file path is *.accde then Msgbox "The file extension is accde"

How can I do that ?
If u know to do this in access 2003 or older versions just tell it to me pls and I will try it to 2007.
Thanks in advnaced.
Not sure how this can be handled, exipnakias!

I know below to work when we need to add/submit to a database, in the current directory, perhaps it can be mastered to do otherewise:

Expand|Select|Wrap|Line Numbers
  1.  
  2. App.Path + "\MyDatabase.mdb"
  3.  
  4.  
Come to think of it, try Google "VB to read Windows Processes in Task Manager", see what happens.

Will forward to Access forum for added support, please stay tuned!

Dököll
Dec 2 '07 #2
The extension really does not determine the actual file format. You can change the extension to from accdb manually (in Windwos Explorer) to accde, but the does not change the actual format. The point I am trying to make is that checking the extension is not the most reliable way to test the format.

I use this in Access 97 to 2003:
How to programmatically determine if your database is in MDE format


To get the name of a database:
Expand|Select|Wrap|Line Numbers
  1. ? Currentproject.name
  2. Northwind.mdb
  3.  
Hope this Helps...
Boyd Trimmell
aka Hi Tech Coach


Dear Sirs/Madams,

Let me ask you a question about a Visual Basic Code in Access 2007.

I try to do a simple thing (as I believe) but I do not know how.
I want a code that will check the extension of the current Access 2007 Database file and give a spesific msg.

For example, I need a code that will find the path of the running database
ex: "C:\test.accdb" and will check the following:

If the file path is *.accdb then Msgbox "The file extension is accdb"
If the file path is *.accde then Msgbox "The file extension is accde"

How can I do that ?
If u know to do this in access 2003 or older versions just tell it to me pls and I will try it to 2007.
Thanks in advnaced.
Dec 2 '07 #3
Thank you for your help guys.

Yesterday, by searching the net I managed to find "Currentproject.name" command which HiTechCoach posted.

It works great. If someone changes the extension of the file (or the name but this does not matther) the wanted msg will appear.

The aim was to check the extsension of the file. This command checks the name and the extension so the wanted msg will also appear when someone changes only the name (not extension) but this is ok for me, this command has solved the problem I had.
Dec 2 '07 #4
ADezii
8,834 Expert 8TB
Thank you for your help guys.

Yesterday, by searching the net I managed to find "Currentproject.name" command which HiTechCoach posted.

It works great. If someone changes the extension of the file (or the name but this does not matther) the wanted msg will appear.

The aim was to check the extsension of the file. This command checks the name and the extension so the wanted msg will also appear when someone changes only the name (not extension) but this is ok for me, this command has solved the problem I had.
This will work for you:
Expand|Select|Wrap|Line Numbers
  1. Dim strPathToCurrentDatabase As String, strExtension As String
  2.  
  3. 'Absolute Path to Current Database
  4. strPathToCurrentDatabase = CurrentProject.path & "\" & CurrentProject.Name
  5.  
  6. 'Extract the Extension with period
  7. strExtension = Right$(strPathToCurrentDatabase, Len(strPathToCurrentDatabase) - _
  8.                       InStrRev(strPathToCurrentDatabase, ".") + 1)
  9.  
  10. Select Case strExtension
  11.   Case ".accdb"
  12.     MsgBox "The File extension is: " & ".accdb"
  13.   Case ".accde"
  14.     MsgBox "The File extension is: " & ".accde"
  15.   Case Else
  16.     MsgBox "The File extension is: " & strExtension
  17. End Select
Dec 2 '07 #5
This will work for you:
Expand|Select|Wrap|Line Numbers
  1. Dim strPathToCurrentDatabase As String, strExtension As String
  2.  
  3. 'Absolute Path to Current Database
  4. strPathToCurrentDatabase = CurrentProject.path & "\" & CurrentProject.Name
  5.  
  6. 'Extract the Extension with period
  7. strExtension = Right$(strPathToCurrentDatabase, Len(strPathToCurrentDatabase) - _
  8.                       InStrRev(strPathToCurrentDatabase, ".") + 1)
  9.  
  10. Select Case strExtension
  11.   Case ".accdb"
  12.     MsgBox "The File extension is: " & ".accdb"
  13.   Case ".accde"
  14.     MsgBox "The File extension is: " & ".accde"
  15.   Case Else
  16.     MsgBox "The File extension is: " & strExtension
  17. End Select

This is the best solution for my problem. Thank u!
Dec 3 '07 #6
ADezii
8,834 Expert 8TB
This is the best solution for my problem. Thank u!
You are quite welcome, exipnakias.
Dec 3 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jsWalter | last post by:
I have an extension Class to Auth and I'm looking for some folks to hammer on it a bit and give feed back. Class: AuthUser - add user (well, Auth does that now, so its gone) - remove user...
6
by: Gyger | last post by:
Hello, Three weeks ago, I have started to develop a binding extension for Qt and PHP 5. Now, I can display a dialog box containing some widgets like label, buttons and edit line. I have just...
0
by: Mark English | last post by:
Basic problem: If there is a C-extension module in a package and it tries to import another python module in the same package without using the fully qualified path, the import fails. Config:...
4
by: Mike Jansen | last post by:
Does anyone know why if I create a complexType based off another complexType using xsd:extension the attributes don't seem to be inherited? Is this a bug/non-implementation in the .NET Schema...
4
by: L Mehl | last post by:
Hello -- I am using Enterprise Architect, a UML modeling tool, which is built on a pre-Access 2000 mdb. The database describing the model has the extension ".eap". I want to build some...
6
by: J. Shrimp, Jr. | last post by:
Following code exports tables as text files: For Each tdf In db.TableDefs StrTblName = tdf.Name Me.txtProgName = StrTblName Me.txtProgName.Requery tblAtt = tdf.Attributes moddate =...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
1
by: Petr Prikryl | last post by:
Do you think that the following could became PEP (pre PEP). Please, read it, comment it, reformulate it,... Abstract Introduction of the mechanism for language extensions via modules...
8
by: john6630 | last post by:
I am trying to get PDO for sqlite to work on my localhost system. I have modified the PHP5.ini file as shown below and run the following PHP script. As stated below, it reports the mssql, mysql and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.