Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Join Date
    Oct 2005
    Posts
    55

    Unanswered: Help with microsoft access database

    I am trying the code below to open a microsoft access database using another microsoft access database and when I run the code the database that is being opened just flashes once and does not stay open? What do I have to do for the database being open to say open?

    Any help will be greatly a appreciated!

    Thanks!


    Private Sub Command0_Click()

    Dim oAcc As Access.Application
    Set oAcc = GetObject("C:\JMS.mdb")
    oAcc.Visible = True

    'Initialize string to database path.
    Const strConPathToSamples = "C:\JMS.mdb"

    strDB = strConPathToSamples & "JMS.mdb"
    ' Create new instance of Microsoft Access.
    Set appAccess = _
    CreateObject("Access.Application")
    ' Open database in Microsoft Access window.
    appAccess.OpenCurrentDatabase strConPathToSamples
    ' Open Orders form.
    appAccess.DoCmd.OpenForm "frmSplash"

    End Sub

  2. #2
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Do you really need to control the forms from the other program or can you simply just open the database using other code?
    Based on DAO 3.6 and Access 2000 + 2003
    VB.Net 2005 + ADO.Net

  3. #3
    Join Date
    Oct 2005
    Posts
    55
    Yes I need to control the forms from another program. So can you help?

    Thanks

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    I don't quite see what's going on with your code (what happens to oAcc and where does appAccess come from?).

    Some (simple) working Access Automation code:
    Code:
    Public Function fAccAutomation() As Boolean
     
        Dim oAcc As Access.Application
     
        Set oAcc = New Access.Application
     
        oAcc.OpenCurrentDatabase "C:\test.mdb", False
     
        oAcc.Visible = True
     
        oAcc.DoCmd.OpenForm "form1"
     
        fAccAutomation = True
        Set oAcc = Nothing
     
    End Function
    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Sorry this is out of my league, i have never experimented with such an application?

    If you just wanted to open the application then yeah i could have helped, i wasnt sure if you where just over complicating a situation.

    Why do you need to control the other database controls anyway, just out of curiosity?
    Based on DAO 3.6 and Access 2000 + 2003
    VB.Net 2005 + ADO.Net

  6. #6
    Join Date
    Oct 2005
    Posts
    55
    Thanks very very much pootleflump the code you send me work!!!!

  7. #7
    Join Date
    Oct 2005
    Posts
    55
    I have another microsoft access database.

    This database generated distance travel. I have two combo boxes the first has the FROM locations and the to has the TO locations.

    What I have done is to have two same name locations in my TO combobox eg. "Couva" as a place would show up twice in the combobox but the actual information to be shown would be different.

    Each "Couva" has a unique ID. what happens when try to get information when I chose the First "Couva" that shows in the combobox I get the right information. But when I select the second "Couva" I would get the same information as the first which is WRONG!

    Why is this happening if they both have a unique ID?

    Your help will be great! THANKS

  8. #8
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Where is the information being shown?

    Do you fill out the form fields with the information from the combobox?

    There is no logical reason why this is working unless you trigger a load of code to go and fill a load of fields in when a selection has been made in the combo box
    Based on DAO 3.6 and Access 2000 + 2003
    VB.Net 2005 + ADO.Net

  9. #9
    Join Date
    Oct 2005
    Posts
    55
    The information is being shown in a Text box!

    Information is entered using a combobox!

    Information is retrived using a combobox!

    The problem is if I have the same name shown twice and they have different information attached to it, I only see the first one not the second!
    seems as though only the first information is seen and not the second.

    Do you think it has to do with my query even though when I run the query I see detailed inform for both! or do I have to used both the Unique ID and PLACE?

  10. #10
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    I dont see if there would be any problem with your query unless you never included your id and you performed a GROUP BY on the SQL.

    I always include the ID anyway in a combobox and just make it impossible to see, all you have to do is change the size of the columns in the combo box and set the first size as zero (So long as the ID is the first field)
    Based on DAO 3.6 and Access 2000 + 2003
    VB.Net 2005 + ADO.Net

  11. #11
    Join Date
    Oct 2005
    Posts
    55
    So I am using this piece of code

    Set oAcc = GetObject("//gis80\C:\SODMIS\DB\TIPS.mdb")

    I am try to navigate to a database that in on another computer an the above is how I type in the code but it is not working what am I doing wrong?

    You help will be greatful

    Thanks

  12. #12
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    I personnally wouldn't do it that way (GetObject I mean) however does this work:

    Set oAcc = GetObject(\\gis80\C$\SODMIS\DB\TIPS.mdb)

    ??
    Testimonial:
    pootle flump
    ur codings are working excelent.

  13. #13
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by Greenway
    ...\SODMIS\....
    Lol - nice path.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  14. #14
    Join Date
    Oct 2005
    Posts
    55
    Hi pootle flump,

    The code did not work I am getting an error message

    " File name or class name not found during automation operation" and when I hite the debug is goes to the line below and highlights it

    Set oAcc = GetObject(\\gis80\C$\SODMIS\DB\TIPS.mdb)

    You said that personally you wouldn't do it that way (GetObject) what other way would you do it or suggest I use?

    Heres my code:

    Private Sub Command8_Click()

    Dim oAcc As Access.Application

    Set oAcc = GetObject("//gis80\C:\SODMIS\DB\TIPS.mdb")

    oAcc.Visible = True

    Const strConPathToSamples = "//gis80\C:\SODMIS\DB\TIPS.mdb"

    strDB = strConPathToSamples & "TIPS.mdb"

    Set appAccess = _ CreateObject("Access.Application")

    appAccess.OpenCurrentDatabase strConPathToSamples

    appAccess.DoCmd.OpenForm "Startup"

    End Sub


    Thanks in advance for your help

  15. #15
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hmmm. Well for starters - I would use the OpenCurrentDatabase rather than CreateObject. They do the same thing so how come you use both methods? And how come you have two access application objects opening the same db? And woudldn't

    Code:
    Const strConPathToSamples = "//gis80\C:\SODMIS\DB\TIPS.mdb"
    
    strDB = strConPathToSamples & "TIPS.mdb"
    mean strDB = //gis80\C:\SODMIS\DB\TIPS.mdbTIPS.mdb
    ??

    Anyway - apart from all that - your server is called gis80 correct? And on that server there is a file called C:\SODMIS\DB\TIPS.mdb correct?
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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