Results 1 to 1 of 1
  1. #1
    Marvin is offline Novice
    Windows Vista Access 2007
    Join Date
    Jul 2009
    Posts
    1

    ADO.Recordset - Write

    Hello everybody, I'm new in here!
    I would like to share with you a problem that I'm facing with Access 2007 - I'm working on a db that should do a particular operation when clickin on button: The software should get in input a string, search on a column of a table all records with that string than insert new rows in a table corresponding to all records that has been previously selected. For doing this I wrote a code step, that I post here:

    *******************************
    Code:
    Private Sub Comando39_Click()
    
    Dim rset_attivita As New ADODB.Recordset
    Dim rset_scadenze As New ADODB.Recordset
    Dim adempimento As String
    Dim id_cliente As Integer
    
    
    'INITIALIZING RECORDSET
    rset_attivita.Open "Attivita", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    rset_scadenze.Open "Scadenze", CurrentProject.Connection, adOpenDynamic
    
    
    'DATA RETRIEVAL
    
    adempimento = InputBox("Inserire il nome dell'adempimento da associare al cliente")
    id_cliente = InputBox("Inserire il codice del cliente 'facciamo la prova passandogli a mano il parametro")
    
    
    'SEARCH ALL "SCADENZE" OF "ADEMPIMENTO" AND CREATION OF NEW RECORDS
    rset_scadenze.MoveFirst
    Do Until rset_scadenze.EOF
     If adempimento = rset_scadenze!adempimento Then
      rset_attivita.MoveLast 'jumps to the end of the recordset
      rset_attivita.AddNew 'creates a new record
       rset_attivita!id_cliente = id_cliente
       rset_attivita!id_scadenza = rset_scadenze!id_scadenza
       rset_attivita!nome_scadenza = rset_scadenze!nome_scadenza
       rset_attivita!adempimento = rset_scadenze!adempimento
       rset_attivita!categoria = rset_scadenze!categoria
       rset_attivita!scadenza = rset_scadenze!scadenza
       rset_attivita!descrizione = rset_scadenze!descrizione
      rset_attivita.Update 'updates the recordset
     Else
      rset_scadenze.MoveNext
    End If
    Loop
    
    
    'CLOSES THE CONNECTION
    rset_attivita.Close
    rset_scadenze.Close
    
    Set rset_attivita = Nothing
    Set rset_scadenze = Nothing
    
    End Sub
    *******************************

    The problem starts when I try to run the code by clicking on the button, I get this error:
    "The expression on click set in the event property has generated the following error: error of communication with OLE server or with ActiveX Control"

    [img=http://img29.imageshack.us/img29/5694/errorea.th.jpg]

    I can't understand this silly problem because in the VBA editor I HAVE ACTIVATED THE references for ActiveX DataObject 2.0 (In VBA editor => tools => references) and I'm also pretty sure that the code that I wrote is correct. So I'm getting very nervous because I can't even check if my procedure is correct, I got stuck in this error and I can't continue my work.

    If some one has any idea please contact me!

    Thank you,


    Marvin
    Last edited by Marvin; 07-19-2009 at 10:17 AM.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Write excel expression in access
    By ktmchugh in forum Queries
    Replies: 0
    Last Post: 07-01-2009, 02:47 PM
  2. Access 2003 returns empty recordset
    By Leelers in forum Queries
    Replies: 0
    Last Post: 03-20-2009, 11:11 AM
  3. write a query how to???
    By flamingo in forum Queries
    Replies: 0
    Last Post: 01-13-2009, 03:57 AM
  4. Create a recordset for a report
    By vjboaz in forum Programming
    Replies: 0
    Last Post: 11-18-2008, 03:28 PM
  5. Add new Recordset using Recorset by Query
    By gailoni in forum Programming
    Replies: 1
    Last Post: 10-22-2008, 11:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums