ADO from within ms access

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yash

    #1

    ADO from within ms access

    Dear all,

    I have a form within the forms tab of my .mdb file with combo boxes
    filled with data from my master tables. The user needs to select his
    choice from these combo boxes and press the Go button. the GO_click
    event is supposed to open a recordset based on the parameters provided
    by the user.

    My question: how do i set the activeconnectio n property of the
    recordset? creating a connection object with full path of db is
    returning an error saying that the database is locked for use.

    I have seen that is case of dao, currentdb object is used to set the
    database. what is the procedure in ADO.

    Please help!!
    Thanks in advance,
    Yash Poddar

  • Nick Coe \(UK\)

    #2
    Re: ADO from within ms access

    CurrentProject. Connection should return the current active
    connection.

    So you could use something like:

    Dim cn As ADODB.Connectio n
    Dim rst As ADODB.Recordset

    Set cn = CodeProject.Con nection
    Set rst = New ADODB.Recordset

    'blah blah blah

    rst.Open YourTableName, cn, adOpenStatic, adLockPessimist ic,
    adCmdTableDirec t

    'blah blah blah

    'And put the following in just before the end to ensure
    everything is closed properly

    If Not rst Is Nothing Then
    rst.Close
    Set rst = Nothing
    End If
    If Not cn Is Nothing Then
    Set cn = Nothing
    End If

    --
    Nick Coe (UK)

    pAnimal - Pedigrees and Breeding - Free 30 day trial
    AccHelp - Skeleton Help for Access Apps
    http://www.pjandcoe.co.uk TShirts with Bark factor... :-)


    In
    news:1113481028 .819270.153080@ f14g2000cwb.goo glegroups.com,
    Yash typed:[color=blue]
    > Dear all,
    >
    > I have a form within the forms tab of my .mdb file with
    > combo
    > boxes filled with data from my master tables. The user
    > needs
    > to select his choice from these combo boxes and press the
    > Go
    > button. the GO_click event is supposed to open a recordset
    > based on the parameters provided by the user.
    >
    > My question: how do i set the activeconnectio n property of
    > the
    > recordset? creating a connection object with full path of
    > db is
    > returning an error saying that the database is locked for
    > use.
    >
    > I have seen that is case of dao, currentdb object is used
    > to
    > set the database. what is the procedure in ADO.
    >
    > Please help!!
    > Thanks in advance,
    > Yash Poddar[/color]


    Comment

    Working...