No worries... Me understand... My battle cry is "Bad spellers of the world...
Untie".
Here is my code for an Access query. It accepts the Pieces of an SQL
statement and returns either a connected or disconnected record set. The
connected recordset is great as you can make you changes and just write them
back with an update statement...
Option Explicit
'Declare Module Level Constants
Private Const m_cDBLocation As String = "C:\MyDatabse.mdb"
Public Function RunQuery(ByVal strSelect As String, ByVal strFrom As String, _
ByVal strWhere As String, ByVal strOrderBy, ByVal blnConnected As Boolean)
As ADODB.Recordset
Dim strConnection As String
On Error GoTo ErrorHandler
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
m_cDBLocation & ";"
Set RunQuery = New ADODB.Recordset
With RunQuery
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockBatchOptimistic
End With
RunQuery.Open strSelect & " " & strFrom & " " & strWhere & " " &
strOrderBy, strConnection, , , adCmdText
If blnConnected = False Then Set RunQuery.ActiveConnection = Nothing
End Function
Sub Example()
Dim rst As ADODB.Recordset
Set rst = RunQuery("Select *", "From tblMyTable", "", ";", False)
End Sub
This requires a reference to the ADODB library...
--
HTH...
Jim Thomlinson
"Ron de Bruin" wrote:
Thanks
I am also an beginner with Access so I hope it is useful for others
Will add another page soon for sending info to Access
My only comment would be the second line on the page is
My English is bad<g, I go change that now Jim
--
Regards Ron de Bruin
http://www.rondebruin.nl
"Jim Thomlinson" wrote in message
...
Very nice addition to your site Ron. I have not downloaded the workbooks yet
but I like the very generic and easy to follow way you create your SQL
statement. I will in all likelyhood borrow some of your code for that. I use
something similar but not as easy for the average non-SQL person to
impliment. My only comment would be the second line on the page is "I go try
to change that on this webpage."
--
HTH...
Jim Thomlinson
"Ron de Bruin" wrote:
See this example
http://www.rondebruin.nl/accessexcel.htm
I like the second example workbook where you can save the criteria
--
Regards Ron de Bruin
http://www.rondebruin.nl
"grahammal" wrote in message
...
How can I use an access data base from within Excel.
I already have all the information that is in this database in a
seperate worksheet and search this when I need to do so. I believe that
the search
criteria and speed is far better if I could utilise an access database
but dont know how to do this from within excel. I would like to achieve
this with a bit of VB behind a commandbutton.
Have I asked too much in one question.
--
grahammal
------------------------------------------------------------------------
grahammal's Profile: http://www.excelforum.com/member.php...o&userid=20336
View this thread: http://www.excelforum.com/showthread...hreadid=510665