Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2006

Tip: Looking for answers? Try searching our database.

Excel not Access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fred - 17 Jan 2006 06:30 GMT
I have designed an Access database that holds  records relating to my stores
audit results going back for about 5 years plus a load more information
relating to these stores. This was used to produe a pack once a month,
however a change in senior management means that I have got to shelve this
and prodce a similar pack  in Excel.

The idea would be that the user could select a month or a 12 mnth date range
that would produce data that could then be used to populate a number of excel
templates that have been designed. Having not used excel for years I would be
grateful for any suggestions on what route to take.

Thanks
Bob Phillips - 17 Jan 2006 08:14 GMT
Are you familiar with SQL? If so, you could keep the Access database and use
ADO to retrive the data to Excel, and then do the report in Excel. The SQL
could be parameter driven to get the month or range of data required. Here
is an example of some Access data maintenance macros

Sub AddData()
Dim oConn As Object
Dim oRS As Object
Dim sSQL As String

   Set oConn = CreateObject("ADODB.Connection")
   oConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=" & "c:\bob.mdb"

   sSQL = "INSERT INTO Contacts (FirstName, LastName,Phone, Notes) " & _
          "        VALUES ('Bob','Phillips','01202 345678','me')"
   oConn.Execute sSQL

   oConn.Close
   Set oConn = Nothing
End Sub

Sub GetData()
Const adOpenForwardOnly As Long = 0
Const adLockReadOnly As Long = 1
Const adCmdText As Long = 1
Dim oRS As Object
Dim sConnect As String
Dim sSQL As String
Dim ary

   sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & "c:\bob.mdb"

   sSQL = "SELECT * From Contacts"
   Set oRS = CreateObject("ADODB.Recordset")
   oRS.Open sSQL, sConnect, adOpenForwardOnly, _
               adLockReadOnly, adCmdText

   ' Check to make sure we received data.
   If Not oRS.EOF Then
       ary = oRS.getrows
       MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)
   Else
       MsgBox "No records returned.", vbCritical
   End If

   oRS.Close
   Set oRS = Nothing
End Sub

Sub UpdateData()
Const adOpenForwardOnly As Long = 0
Const adLockReadOnly As Long = 1
Const adCmdText As Long = 1
Dim oConn As Object
Dim oRS As Object
Dim sConnect As String
Dim sSQL As String
Dim ary

   sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & "c:\bob.mdb"

   sSQL = "SELECT * From Contacts"
   Set oRS = CreateObject("ADODB.Recordset")
   oRS.Open sSQL, sConnect, adOpenForwardOnly, _
               adLockReadOnly, adCmdText

   ' Check to make sure we received data.
   If oRS.EOF Then
       MsgBox "No records returned.", vbCritical
   Else
       sSQL = "UPDATE Contacts  " & _
              "       SET Phone = 'None' " & _
              "WHERE FirstName = 'Bob' AND LastNAme = 'Phillips'"
       oRS.ActiveConnection.Execute sSQL

       sSQL = "SELECT * From Contacts"
       oRS.ActiveConnection.Execute sSQL
       ary = oRS.getrows
       MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)
   End If

   oRS.Close
   Set oRS = Nothing
End Sub

--
HTH

RP
> I have designed an Access database that holds  records relating to my stores
> audit results going back for about 5 years plus a load more information
[quoted text clipped - 8 lines]
>
> Thanks
Ron de Bruin - 18 Jan 2006 18:03 GMT
I add also a few examples on my site yesterday
Will add more soon

http://www.rondebruin.nl/accessexcel.htm

Signature

Regards Ron de Bruin
http://www.rondebruin.nl

> Are you familiar with SQL? If so, you could keep the Access database and use
> ADO to retrive the data to Excel, and then do the report in Excel. The SQL
[quoted text clipped - 104 lines]
>>
>> Thanks
LeAnne - 17 Jan 2006 15:41 GMT
Hi fred,

Thanks to ODBC you're not limited to one app over the other. Since you
have worked in Access and are likely familiar with SQL and using
queries, I recommend using MS Query. Open a blank Excel spreadsheet and
select Data | Import External Data | New Database Query.  When the
Choose Data Source window opens, select MS Access Database. NOTE: MAKE
SURE that the "Use the Query Wizard to create/edit queries" is
UNCHECKED...this is because the Query Wiz is stupid & does not know
about joins.  Click OK. From the Select Database window, find your .mdb
file and select it. MS Query will open a GUI that looks very similar to
the Access QBE grid, and a list of database objects (click the Options
buttons and make sure all boxes are checked), including queries. Add the
desired objects to your query. Note that MS Query cannot "see" the
relational joins created in the Access db; you have to join tables on
key fields manually.  Once you save the query, however, it will
remember. The commands are very similar to the Access query window, so
you should have no trouble creating queries, relating objects or setting
criteria; you can even create parameter queries that prompt the user.
After the query has been run, select File | Return data to Microsoft
Office Excel and the recordset will be exported to the spreadsheet you
originally opened, unless you specify otherwise. Save this workbook with
an appropriate name. Any time you wish to requery the data, open the
worksheet, right-click on any cell, and select Edit Query.  It would
probably be fairly simple to set up an Excel User Form to automate the
process so that the user need never see the query.

Tushar Mehta has a nice tutorial with some easy-to-follow examples at
http://www.tushar-mehta.com/excel/newsgroups/rdbms_in_excel/index.html

Hope this helps!

LeAnne

> I have designed an Access database that holds  records relating to my stores
> audit results going back for about 5 years plus a load more information
[quoted text clipped - 8 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.