Basic splitting and VBA code that no longer works

beodeo Posted messages 8 Status Member -  
beodeo Posted messages 8 Status Member -
Hello,

I have just split my Access database.
My code was working perfectly before, but now, when I close my "contacts" form, the execution of code modifying the "contacts" table (the source table of the form) results in an execution error 3048 ("Cannot open more databases").

Excerpt from the code:

Dim DistantDB As DAO.Database Dim SQLcode2 as String SQLcode2 = "DELETE [RETOUR FORMULAIRE PRECEDENT].* FROM [RETOUR FORMULAIRE PRECEDENT];" DistantDB.Execute SQLcode2 DistantDB.Close Set DistantDB = Nothing


My code stops at:

DistantDB.Execute SQLcode2


Thank you

Configuration: Windows 7 / Internet Explorer 9.0

3 answers

  1. blux Posted messages 2045 Registration date   Status Moderator Last intervention   3 455
     
    Hi,

    What does DistantDB contain?
    Because I don't see it taking any value in your code...

    --
    See you, blux
     "You can't trust idiots. That's how you recognize them." 
    0
  2. beodeo Posted messages 8 Status Member
     
    Good evening,

    oops I forgot a line

    Dim DistantDB As DAO.Database Dim SQLcode2 as String SQLcode2 = "DELETE [RETOUR FORMULAIRE PRECEDENT].* FROM [RETOUR FORMULAIRE PRECEDENT];" Set DistantDB = CurrentDb DistantDB.Execute SQLcode2 DistantDB.Close Set DistantDB = Nothing
    0
    1. blux Posted messages 2045 Registration date   Status Moderator Last intervention   3 455
       
      Which version of Access?
      Which version of DAO in the references?
      0
  3. beodeo Posted messages 8 Status Member
     
    small clarifications:
    1/: I brought my table local and now there are no more issues...
    but with the connection, I still get the same error message.
    2/: in my form, I have sub-forms that use this famous table as a source via queries.

    if this helps clarify things further...
    0
    1. blux Posted messages 2045 Registration date   Status Moderator Last intervention   3 455
       
      As I asked before:
      What version of Access?
      What version of DAO in the references?

      Is your code clean? Do you properly delete objects after using them (set ... = nothing)?
      0
    2. beodeo Posted messages 8 Status Member
       
      Access version: 2002/2003
      DAO version: 3.6

      I constantly delete objects after using them...
      and I think I can say that my code is clean (well, almost...)
      0
    3. blux Posted messages 2045 Registration date   Status Moderator Last intervention   3 455
       
      There is a limit of 255 'connected objects' open in Access. Maybe you're at the limit?
      0
    4. beodeo Posted messages 8 Status Member
       
      Does using this table multiple times in subforms can cause "interferences" with the SQL code (which also modifies it with DELETE)?
      0
    5. blux Posted messages 2045 Registration date   Status Moderator Last intervention   3 455
       
      I can't be categorical.
      If necessary, if you do a lot of VBA, you could use transactions for updates...
      0