I think I solved the Login problem changing this line:
sDB = Right(sPath, Len(sPath) - InStrRev("\", sPath) - 1)
to:
sDB = Right(sPath, Len(sPath) - InStrRev("\", sPath) - 3)
Now the problem is with the Refresh portion.
Run-time error '1004', SQL Syntax Error.
It points at: .Refresh...
Using the Debug method... I found this:
sConn in its line: DBQ is: DBQ=E:\DBfolder\E:\DBname.mdb...
I suspect the sSQL , FROM clause is also wrong...
What should I change?
hey PHV,
I have included what you said, the code is this:
Sub AccessData()
Dim sConn As String, sSQL As String, sPath, sDB As String
sPath = Application.GetOpenFilename("Access Files (*.mdb), *.mdb")
If sPath <> False Then
sPath = Left(sPath, InStrRev(sPath, "\")...
The vba code was a macro recorded from the following SQL statement:
SELECT DISTINCT OWNERS.WELL, OWNERS.OPERATOR, OWNERS.SEARCHID
FROM `E:\X Folder\X database`.OWNERS OWNERS
GROUP BY OWNERS.WELL, OWNERS.OPERATOR, OWNERS.SEARCHID
HAVING (OWNERS.SEARCHID<>'1' And OWNERS.SEARCHID Not Like '%U')...
The original . Recorded Macro for this code is:
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=E:\OK.mdb;DefaultDir=E:\;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5" _
), Array(";UID=admin;"))...
I have this so far:
Sub AccessData()
Dim sConn As String, sSQL As String, sPath, sDB As String
sPath = Application.GetOpenFilename("Access Files (*.mdb), *.mdb")
If sPath <> False Then
sPath = Left(sPath, InStrRev(sPath, "\") - 1)
sDB = Right(sPath, Len(sPath) -...
NO results, Just the Error....
I ma using Excel just to filter and handle some records as filtered using SQL statement, then I use other methods to export and automate Access.
Which lines should I put the Debug.print???
?
The dabatases are located in an external hard drive, I work with each single one of them, and then I place the results on a Main database.
How would the final code be?..
It is giving me the "error 438; Object doesn't support this property or method.
Pointing at:
.Connection = sConn
:(
Sorry I am new to the VBA environment....
The vba code was a macro recorded from the following SQL statement:
SELECT DISTINCT OWNERS.WELL, OWNERS.OPERATOR, OWNERS.SEARCHID
FROM `E:\X Folder\X database`.OWNERS OWNERS
GROUP BY OWNERS.WELL, OWNERS.OPERATOR, OWNERS.SEARCHID
HAVING (OWNERS.SEARCHID<>'1' And OWNERS.SEARCHID Not Like '%U')...
Hi,
I have a question, I am using the Get External data option in Excel to pull an Access database onto my excel spreasheet, though, everytime I want to use it the database has a different location. How can I change the code in vba for me to prompt me a location, in the code I attached below...
Skipvought,
Thank you very much for that answer, I am testing the code... However...
I want sDB to catch the PATH and Database name, since it is a different name eveytime !!!! say: same drive E:\ same folder , different database names....
thanks,
Hi,
I have a question, I am using the Get External data option in Excel to pull an Access database onto my excel spreasheet, though, everytime I want to use it the database has a different location. How can I change the code in vba for me to prompt me a location, in the code I attached below...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.