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 / March 2008

Tip: Looking for answers? Try searching our database.

Excel as Access front end

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BillE - 20 Mar 2008 20:27 GMT
I am looking for advice on using Excel as an Access front end for data
entry.  I googled this and found code for using DAO/ADO.  I'm just wondering
if anyone has any good links for further suggestions.

Thanks
Bill
JP - 20 Mar 2008 20:49 GMT
I have some code on my site:

http://tinyurl.com/32994k

HTH,
JP

> I am looking for advice on using Excel as an Access front end for data
> entry.  I googled this and found code for using DAO/ADO.  I'm just wondering
> if anyone has any good links for further suggestions.
>
> Thanks
> Bill
Bob Phillips - 20 Mar 2008 21:04 GMT
Here is some code

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

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

>I am looking for advice on using Excel as an Access front end for data
>entry.  I googled this and found code for using DAO/ADO.  I'm just
>wondering if anyone has any good links for further suggestions.
>
> Thanks
> Bill
BillE - 20 Mar 2008 21:27 GMT
Thanks!

>I am looking for advice on using Excel as an Access front end for data
>entry.  I googled this and found code for using DAO/ADO.  I'm just
>wondering if anyone has any good links for further suggestions.
>
> Thanks
> Bill

Rate this thread:






 
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.