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