Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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

Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     

Share This Page