Open Access database Form from VB 6.0?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Open Access database Form from VB 6.0?

  1. #1
    Demo Guest

    Open Access database Form from VB 6.0?


    Dear friends,

    If I wanted to open up a form that is created in Access, how would I write
    the code?

    Ex:
    Dim adoconnection As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim connectstring As String

    Set adoconnection = New ADODB.Connection
    Set rs = New ADODB.Recordset

    connectstring = "provider=microsoft.jet.oledb.3.51;" _
    & "data source=L:\vbInventory\inventory.mdb"

    adoconnection.Open connectstring

    See here is where I find myself lost in the sense that I want to open a specific
    form in my inventory.mdb. I have the connection but I want to know how I
    should write a code to open up the form called Inventory. What I want the
    user to be able to do is go from VB to my Access database and work within
    my Access database.

    See, I have set up my Access App. to open through the use of STARTUP, opening
    at the Inventory form and have created specific toolbars for the user to
    go through by database from there on.

    I just need some help going from VB 6 to Access, how do you go about writing
    the code for this? Can you or someone else please help me here?

    Thanks in advance,

    Demo
    Junior Programmer



  2. #2
    Douglas J. Steele Guest

    Re: Open Access database Form from VB 6.0?

    I'm not 100% certain that you CAN get to the Access forms as you'd like,
    although you can get to Access reports using Automation. See
    http://support.microsoft.com/support.../Q147/8/16.ASP for more
    details.

    --

    Doug Steele, Microsoft Access MVP
    Beer, Wine and Database Programming. What could be better?
    Visit "Doug Steele's Beer and Programming Emporium"
    http://I.Am/DougSteele/


    Demo <demo@ddt1.com> wrote in message news:392e84f3$1@news.devx.com...
    >
    > Dear friends,
    >
    > If I wanted to open up a form that is created in Access, how would I write
    > the code?
    >
    > Ex:
    > Dim adoconnection As ADODB.Connection
    > Dim rs As ADODB.Recordset
    > Dim connectstring As String
    >
    > Set adoconnection = New ADODB.Connection
    > Set rs = New ADODB.Recordset
    >
    > connectstring = "provider=microsoft.jet.oledb.3.51;" _
    > & "data source=L:\vbInventory\inventory.mdb"
    >
    > adoconnection.Open connectstring
    >
    > See here is where I find myself lost in the sense that I want to open a

    specific
    > form in my inventory.mdb. I have the connection but I want to know how I
    > should write a code to open up the form called Inventory. What I want the
    > user to be able to do is go from VB to my Access database and work within
    > my Access database.
    >
    > See, I have set up my Access App. to open through the use of STARTUP,

    opening
    > at the Inventory form and have created specific toolbars for the user to
    > go through by database from there on.
    >
    > I just need some help going from VB 6 to Access, how do you go about

    writing
    > the code for this? Can you or someone else please help me here?
    >
    > Thanks in advance,
    >
    > Demo
    > Junior Programmer
    >
    >




  3. #3
    Dale Gravatt Guest

    Re: Open Access database Form from VB 6.0?


    Demo,

    I posted a response to this question in the Getting Started newsgroup. It
    has sample code which can be placed on a form with three buttons (cmdOpen,
    cmdClose, cmdQuit). You'll also need to edit the database filename and form
    and report names to match a database on your local machine.

    Dale

  4. #4
    Ed Guest

    Re: Open Access database Form from VB 6.0?


    Dim accObj As New Access.Application
    accObj.OpenCurrentDatabase YourDBHere
    accObj.DoCmd.OpenForm FrmName, acNormal, , , acFormEdit, acWindowNormal

    Now of course you will have to replace YourDBName with the DB Name and path
    and FrmName with the name of the Access Form

    it is easier if you reference the Access Object and declare the variable
    more like this

    Public accObj as New Access.Application

    That will auto fill your options for ya

    "Demo" <demo@ddt1.com> wrote:
    >
    >Dear friends,
    >
    >If I wanted to open up a form that is created in Access, how would I write
    >the code?
    >
    >Ex:
    >Dim adoconnection As ADODB.Connection
    >Dim rs As ADODB.Recordset
    >Dim connectstring As String
    >
    >Set adoconnection = New ADODB.Connection
    >Set rs = New ADODB.Recordset
    >
    >connectstring = "provider=microsoft.jet.oledb.3.51;" _
    > & "data source=L:\vbInventory\inventory.mdb"
    >
    >adoconnection.Open connectstring
    >
    >See here is where I find myself lost in the sense that I want to open a

    specific
    >form in my inventory.mdb. I have the connection but I want to know how

    I
    >should write a code to open up the form called Inventory. What I want the
    >user to be able to do is go from VB to my Access database and work within
    >my Access database.
    >
    >See, I have set up my Access App. to open through the use of STARTUP, opening
    >at the Inventory form and have created specific toolbars for the user to
    >go through by database from there on.
    >
    >I just need some help going from VB 6 to Access, how do you go about writing
    >the code for this? Can you or someone else please help me here?
    >
    >Thanks in advance,
    >
    >Demo
    >Junior Programmer
    >
    >



  5. #5
    Jacqui Ferguson Guest

    Re: Open Access database Form from VB 6.0?


    To: Dale Gravatt: Thanks for the code, but for me (a complete novice) I
    keep getting the same error
    msg:
    "User defined type not defined" on the very first Dim statement. What am
    I missing?

  6. #6
    Mario Guest

    Re: Open Access database Form from VB 6.0?


    I think you are defining the variable to be NOT a VB type. (ie check for spelling)
    [AND DEFINATELY type in at the very top of the module without the quotes
    "Option Explicit"]

    Then ensure that all the libraires your project require are referenced in
    the references dialog.

    For to open a database you will need a reference to DAO [version 3.51 or
    higher if possible]

    then

    Dim db as dao.database ' once you type in the "." intellisense
    ' should present you with a list of
    ' classes, including database

    set db = dbengine.workspaces(0).opendatabase("[path]")





    "Jacqui Ferguson" <jacqui.m.ferguson@lmco.com> wrote:
    >
    >To: Dale Gravatt: Thanks for the code, but for me (a complete novice)

    I
    >keep getting the same error
    > msg:
    >"User defined type not defined" on the very first Dim statement. What am
    >I missing?



  7. #7
    JF Guest

    Re: Open Access database Form from VB 6.0?


    Thanks Mario

  8. #8
    Dave Guest

    Re: Open Access database Form from VB 6.0?


    Could you please tell me how you would connect to a secured access database?
    Thanks

    "Mario " <bmlx@yahoo.com> wrote:
    >
    >I think you are defining the variable to be NOT a VB type. (ie check for

    spelling)
    >[AND DEFINATELY type in at the very top of the module without the quotes
    >"Option Explicit"]
    >
    >Then ensure that all the libraires your project require are referenced in
    >the references dialog.
    >
    >For to open a database you will need a reference to DAO [version 3.51 or
    >higher if possible]
    >
    >then
    >
    >Dim db as dao.database ' once you type in the "." intellisense
    > ' should present you with a list of
    > ' classes, including database
    >
    >set db = dbengine.workspaces(0).opendatabase("[path]")
    >
    >
    >
    >
    >
    >"Jacqui Ferguson" <jacqui.m.ferguson@lmco.com> wrote:
    >>
    >>To: Dale Gravatt: Thanks for the code, but for me (a complete novice)

    >I
    >>keep getting the same error
    >> msg:
    >>"User defined type not defined" on the very first Dim statement. What

    am
    >>I missing?

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center