Hello everybody,
I'm developing a VBA application to control some datas from my workmates. I'm using Excel 2007 for everything, however, I need to consolidate those datas into one simples database.
My workmates are gonna fill some userforms and those form datas are transferred to a new sheet in the same workbook. What I need to do now is:
- When the user click in the SAVE BUTTON, those datas will be transferred to the sheet as I'm doing now AND, I need the same datas transferred to an Access 2007 (.accdb) file.
Nevertheless, I've got a problem in my database code.
Take a look below!
In the end of my SAVE FUNCTION I wrote:
When I run this code, I've got a problem: Run-time error '3265' Item cannot be found in the collection corresponding to the requested name or ordinal. in Line 28.
Please, can anyone help me with this error? I really need to fix it as soon as I can!
EDITING: I'm doing that with only Codigo as Variant (Code as Variant, in English) as a parameter to test my macro. When everything's running clearly, I'll insert other parameters for all of my userforms...
Cheers folks!
I'm developing a VBA application to control some datas from my workmates. I'm using Excel 2007 for everything, however, I need to consolidate those datas into one simples database.
My workmates are gonna fill some userforms and those form datas are transferred to a new sheet in the same workbook. What I need to do now is:
- When the user click in the SAVE BUTTON, those datas will be transferred to the sheet as I'm doing now AND, I need the same datas transferred to an Access 2007 (.accdb) file.
Nevertheless, I've got a problem in my database code.
Take a look below!
Code:
1. Sub Transf_BD(Codigo As Variant)
2.
3. Dim cnn As ADODB.Connection
4. Dim rst As ADODB.Recordset
5.
6. 'Abre a conexão com o Banco de Dados
7. Set cnn = New ADODB.Connection
8.
9. cnn.Open "Provider=Microsoft.Ace.OLEDB.12.0; Persist Security Info = False;" & _
10. "Data Source=C:\BD_Ideia.accdb;"
11.
12. 'Definir o Recordset
13. Set rst = New ADODB.Recordset
14. rst.CursorLocation = adUseServer
15.
16. 'Abre a tabela do Banco de Dados
17. rst.Open Source:="tblTransfer", _
18. ActiveConnection:=cnn, _
19. CursorType:=adOpenDynamic, _
20. LockType:=adLockOptimistic, _
21. Options:=adCmdTable
22.
23. 'Adiciona um Registro
24. rst.AddNew
25.
26. 'Configura os valores para os campos.
27. 'Os campos são passados do userform.
28. rst("Codigo") = "TEST"
29.
30. 'Escreva os valores para este registro
31. rst.Update
32.
33. 'Fechar
34. rst.Close
35. cnn.Close
36
37.End Sub
In the end of my SAVE FUNCTION I wrote:
Code:
Transf_BD (Codigo)
When I run this code, I've got a problem: Run-time error '3265' Item cannot be found in the collection corresponding to the requested name or ordinal. in Line 28.
Please, can anyone help me with this error? I really need to fix it as soon as I can!

EDITING: I'm doing that with only Codigo as Variant (Code as Variant, in English) as a parameter to test my macro. When everything's running clearly, I'll insert other parameters for all of my userforms...
Cheers folks!
Last edited: