Results 1 to 2 of 2

Thread: Outlook VBA

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Question

    Hopefully the title has not put most of you off, under my outlook form (with tab as page1), I have the following code under a commandbutton click event :

    Dim DAO, DAO3, DB, RS
    Set DAO = Application.CreateObject("DAO.DBEngine.35")
    Set DAO3 = DAO.Workspaces(0)
    Set DB = DAO3.OpenDatabase("c:\MydB.mdb")
    Set RS = DB.OpenRecordset("Select * from Table1 _
    Order by Name")

    Dim TxtName
    Set TxtName = Item.GetInspector.ModifiedFormPages _
    ("page1").Controls.Item("TxtName")

    Rs.addnew
    Rs.Name = txtName.text
    Rs.Update


    Now then, I have been using outlook forms for about 4 months, but this is the first time I have tried to access a database with one. I cannot write with ADO, and any samples of DAO with outlook I cannot get to work.

    Could someone please tell me where/how the above code is wrong!?? The above uses a MS Access 97 database (named MydB.mdb) which has 1 table (table1 [I know, very imaginative!]) and this in turn has 1 column (called Name). Thank you.



    Thank you everyone!
    Alex Read


    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    try this as your SQL:

    Set RS = DB.OpenRecordset("Select * from Table1 _
    Order by [Name]")


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width