The code below downloads the test.mdb file but when I try to open it MS Access says it is in an unrecognised format.

Is it not possible to use Inet for downloading an Access database?

Dim strURL As String
Dim bData() As Byte ' Data variable
Dim intFile As Integer ' FreeFile variable

strURL = "http://www.asite/test.mdb"
intFile = FreeFile()
bData() = Inet1.OpenURL(strURL, icByteArray)
Open App.Path & "\test.mdb" For Binary Access Write As #intFile
Put #intFile, , bData()
Close #intFile

Are you sure that the database is in the same format (ie, did you make the database in Access 2007, and are opening it in 2003?)

Good idea but made in 2000 and trying to open it in 2000

Mkay, have you tried opening the original (open it with wordpad or notepad, unless it's huge) and then opening the one downloaded through VB, and see if they are the same size and the same basic byte structure etc? And there is no DB on http://www.asite.com for me to check it myself ;)

Your previous post made me wonder if the database I was using was corrupt. So I just grabbed another, checked it would open OK, posted it to a website, downloaded it OK, but Access doesn't recognise it.

weird...are the file sizes the same and all that?

Just tried open both in Notepad.

Original is gobblydegook

Dowloaded one is bigger and a text file about a missing file

the gobblydegook is fine, that means it's in access format... if the other opens some kind of weird text, then obviously access won't read it.... now the question is, what is this text about missing files?

Just posted a simple text file 1.txt with one word in. Changed the app.path to c:\.1.txt

The text file downloads fine and I can open it and see the word. If I alter the two .txt to .mdb and download the database I can still download it but part of what I find in Notepad is this:

"The type of page you have requested is not served because it has been explicitly forbidden.  The extension '.mdb' may be incorrect.   Please review the URL below and make sure that it is spelled correctly."

It seems to be something to do with Access.

I have to go now will let you know tomorrow if I sort it.

Thanks for your help.

The web server is forbidding the web browser from accessing .mdb files... makes sense for security reasons. On the server, rename the .mdb file to something like "mydatabase.zip" and when you have downloaded the file, have vb rename it to something like "mydatabase.mdb"

That was the problem. I hadn't placed the database in one of my password protected folders so didn't realise there would anything to stop the download.

If I changed the file extension from .mdb to .txt then uploaded it. When I downloaded and saved it as an .mdb file then Access could then recognise it.

Cheers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.