Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Updating an SQL db from an access form

Discussion in 'Information Technology' started by Kevin, Jul 28, 2006.

  1. Kevin

    Expand Collapse

    I have an access project that is linked to an SQL db. I am trying to buld a
    form that user updates. I am having difficluty getting the form to update the
    recordset pulled from the db.

    The db is really simple only a few tables. For my example we only need 2 of
    them. Table 1:

    Table 2:

    Here is the code used to pull a recordset from the db:

    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset

    'Use the ADO connection that Access uses
    Set cn = CurrentProject.AccessConnection

    'Create an instance of the ADO Recordset class, and
    'set its properties
    Set rs = New ADODB.Recordset
    With rs
    Set .ActiveConnection = cn
    .Source = " Select ProjectID, ProjectName, FundingPoolID From
    dbo.SR_Master_Data Where UpdateNeeded = 1"
    .LockType = adLockOptimistic
    .CursorType = adOpenKeyset
    .CursorLocation = adUseClient
    End With

    'Set the form's Recordset property to the ADO recordset
    Set Me.Recordset = rs

    Me.FundingPool.Value = rs("FundingPoolID")

    The executes when the form is opened and returns the expected recordset.

    The form has 3 controls:
    A text box for ProjectID, the control source is set to ProjectID
    A text box for ProjectName, the control source is set to ProjectName
    A combobox for FundingPool, this is linked to Table 2 and is a list of the
    FundingPoolDesc. Its .value is set to the currect record FundingPoolID so
    that is displays the correct FundingPoolDesc.

    I want the user to beable to select a new/different FundingPool from the
    dropdown list and have it update the FungingPoolID for the recordset.
    Currently you can select a different FundingPool from the list but once that
    record losses focus the change is gone. I would like for the uses to update
    all the records returned, then submit the changes to the data base.

    For the life of me and can't get this to update the open recordset, or the
    db. If I can get the open recordset to update I know I can create a sproc on
    the server to update the db.

    Any help would be greatly appreciated.
    Thanks Kevin
  2. Loading...

    Similar Threads Forum Date
    Microsoft Brings 64-Bit Perks in SQL Server 2000 Service Pack (Ziff Davis) Interfaith Dialogues May 7, 2005

Share This Page