Basic splitting and VBA code that no longer works

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

  • Votes
  • Date
  • Descending date
  1. Moderator
    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." 
    1. 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
      1. Moderator
        Which version of Access?
        Which version of DAO in the references?
    2. 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...
      1. Moderator
        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)?
      2. 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...)
      3. Moderator
        There is a limit of 255 'connected objects' open in Access. Maybe you're at the limit?
      4. Does using this table multiple times in subforms can cause "interferences" with the SQL code (which also modifies it with DELETE)?
      5. Moderator
        I can't be categorical.
        If necessary, if you do a lot of VBA, you could use transactions for updates...