Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open databases (97 sr2)

    I have a question. I have a function that opens the current database. Then another function is conditionally called. This second function opens and adds records to a second database. I then conditionally call a third database. I want to add records to a table in the third database.

    Before I go crazy trying to make this work is this something that I should be able to do?

    I am getting the following error message
    Update or CancelUpdate without AddNew or Edit. 3020 DAO.Field

    When I comment out the code to call the third function there is no problem.

    Thanks
    Cathy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open databases (97 sr2)

    I don't understand why you would want to open three databases. Apart from that, we'd need to see the code (or the databases themselves) to know what is happening.

  3. #3
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open databases (97 sr2)

    Hans,
    Thanks so very much...

    I have a (1)database that contains only the functions. Each of these functions process data that is placed into tables in different databases. Management want me to do it this way for security reasons. They want everything processed at one point but disbursed to multiple points.
    It is in one of these functions that I hope to send the same processed data to two different databases. So I basically have (1) database that contains the processing functions, (1) database that hold the tables for group A, and (1) database that holds the tables for group([img]/forums/images/smilies/cool.gif[/img]. I know it is the same data being stored twice but that is the way they insist it happen.

    I want to make sure I can do this before I go crazy .
    Thanks
    Cathy

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open databases (97 sr2)

    You'll have to tell us more about the code you are using.

  5. #5
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open databases (97 sr2)

    Hans,
    Here is the piece of the code that is blowing up. Can you look at it and see what I am doing wrong? I have used this code before with no problem...
    Thanks in advance
    Cathy



    Function Append_DBSX(acct, NFSDatabasePath)
    Dim dbsDBSX As Database
    Dim RstDBSX As Recordset, RstDBSXCount As Recordset
    Dim strsql As String, AcctCt As Integer

    Set dbsDBSX = OpenDatabase(NFSDatabasePath)
    Set RstDBSX = dbsDBSX.OpenRecordset("DBSX", dbOpenDynaset)
    Set RstDBSXCount = dbsDBSX.OpenRecordset("DBSX", dbOpenDynaset)
    AcctCt = 0

    ' check to see if the account is already in the table
    strsql = "select count(*) as RecCount from [DBSX] where [Account_Number] = " & Chr(34) & acct & Chr(34)
    Set RstDBSXCount = dbsDBSX.OpenRecordset(strsql, dbOpenDynaset)
    AcctCt = RstDBSXCount!RecordCount *******THIS IS WHERE IT IS BLOWING UP************************************************ ***

    If AcctCt = 0 Then

    RstDBSX.AddNew
    RstDBSX!ACCOUNT_NUMBER = acct
    RstDBSX!DBSX_SET = True
    RstDBSX.Update
    End If



    RstDBSX.Close
    Set RstDBSX = Nothing


    End Function

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open databases (97 sr2)

    The code looks rather confusing. You open a recordset RstDBSX on the table DBSX, then open another recordset RstDBSXCount on the same table without doing anything with it, then without closing it, open it on an SQL string. You can omit the line

    Set RstDBSXCount = dbsDBSX.OpenRecordset("DBSX", dbOpenDynaset)

    You get an error message because you use RstDBSXCount!RecordCount. RecordCount is a property, not a field. You should use

    AcctCt = RstDBSXCount!RecCount

    instead. You should also close RstDBSXCount and set it to Nothing.

  7. #7
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open databases (97 sr2)

    Hans,
    thanks I found the problem right before I got your reply. RecCount..... I knew it would be something simple and stupid

    Thanks so very much
    Have a wonderful Holiday

    Cathy

Posting Permissions

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