Results 1 to 8 of 8

Thread: Automation

  1. #1
    Join Date
    Nov 2003
    Posts
    34

    Unanswered: Automation

    I am trying to run a section of code from my Access database that is in another Access Database.

    The private sub i'm trying to execute is command46_click. This code checks a frame to see if one of the two radio buttons inside are clicked. How do I automate clicking the radio button so when I run this function the frame will have the correct value?

    This is what I have so far:
    Set dbMyDatabase = CreateObject("Access.Application")
    dbMyDatabase.OpenCurrentDatabase "C:MyDatabase.mdb"

    dbMonthlyPosition.Run "Command46_Click"


    Are there any books you recommend for automation coding?

    Thanks!!!
    "If you are good you will be assigned all the work. If you are really good you will get out of it."

  2. #2
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238

    Re: Automation

    Originally posted by kellywray
    I am trying to run a section of code from my Access database that is in another Access Database.

    The private sub i'm trying to execute is command46_click. This code checks a frame to see if one of the two radio buttons inside are clicked. How do I automate clicking the radio button so when I run this function the frame will have the correct value?

    This is what I have so far:
    Set dbMyDatabase = CreateObject("Access.Application")
    dbMyDatabase.OpenCurrentDatabase "C:MyDatabase.mdb"

    dbMonthlyPosition.Run "Command46_Click"


    Are there any books you recommend for automation coding?

    Thanks!!!

    I don't know if you still need the answer to this or not... but I played around with it for a couple of days and I have figured it out... (I get on these missions... ...)

    You'll have to adapt the code to work with your names but here's what worked for me... (This is the code in my main form module...)

    Function RunAutomation()

    Dim acApp As Object ' Declare variable to hold the reference.
    Dim acDatabase As DAO.Database

    Set acApp = GetObject("C:\Documents and Settings\treaspa\Desktop\db1.mdb") 'Open the database...
    With acApp
    .Visible = True 'make it visible...
    .DoCmd.OpenForm "Form1" 'open the remote form...
    .Forms("Form1").frmOptions = 2 'assign option button value... change as needed...
    .Forms("Form1").cmdDone_Click 'call the command button's click event
    .Quit 'quit access
    End With
    Set acApp = Nothing 'release memory allocated for object variable

    End Function

    Important... In order for your code to work for the command button click event in the remote form... you have to change the scope... Change it from Private to Public...

    Hope this helps...

  3. #3
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238

    Re: Automation

    P.S. As for the books on Automation coding... Sorry... I don't know of any good ones... I'd love to find out... I'm having to do a lot of automation between Microsoft applications lately and I'm basically teaching myself this stuff...

  4. #4
    Join Date
    Nov 2003
    Posts
    34

    Re: Automation

    Thank you for your post! I created a macro in the database I was calling to set the value and then click the button. That, I think will work, but your way will allow me to do the same without altering the called db so i'll definitly give that a try when I get in tomorrow! Thank you for the reply.

    I am also basically teaching myself. I know if you look at the help files in Access they state that it was once called OLE automation. my plan was to look for books under that subject and see if they apply. If there aren't any maybe we should write one!!!

    Thanks again, i'll let you know if it works for what i'm doing!

    Kelly
    "If you are good you will be assigned all the work. If you are really good you will get out of it."

  5. #5
    Join Date
    Nov 2003
    Posts
    34
    Any ideas how to open a table in the remote db, search through a field to see if any records = null, and if so set them to a value?
    "If you are good you will be assigned all the work. If you are really good you will get out of it."

  6. #6
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238
    Originally posted by kellywray
    Any ideas how to open a table in the remote db, search through a field to see if any records = null, and if so set them to a value?
    I would do an update query with SQL... Standard SQL format is...
    UPDATE table
    SET newvalue
    WHERE criteria;

    I don't know your field or table names so I'll just give you a generic example...

    Declare a string variable in your code and assign it a value...
    (SQL taken from Access Help "UPDATE statement" sample... )

    Dim strSQL as string

    strSQL = "UPDATE Orders " & _
    " SET OrderAmount = OrderAmount * 1.1, " & _
    "Freight = Freight * 1.03 " & _
    "WHERE ShipCountry = 'UK';"

    (Then since you've already Set your application object... I believe that something like the following will work... )

    acApp.DoCmd.RunSQL strSQL

    HTH

  7. #7
    Join Date
    Nov 2003
    Posts
    34
    Thank you, this should work!
    "If you are good you will be assigned all the work. If you are really good you will get out of it."

  8. #8
    Join Date
    Nov 2003
    Posts
    9

    Access Automation

    Hullo. You may want to try Access97 (2000 or what not) Developers Handbook. Lot's of good information in there about using Access as either an automation client or server.

    HTH!

    P

Posting Permissions

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