R
Raul Sousa
I use to work with DAO, now I want to start working with
ADO.
I have this code to add a new item to a combo box.
Dim db As DAO.Database
Dim RS As DAO.Recordset
Dim strMsg As String
strMsg = "Bla bla bla"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Field
unknow") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set RS = db.OpenRecordset("Table", dbOpenDynaset)
RS.AddNew
RS.Fields("Field") = NewData
RS.Update
RS.Close
Response = acDataErrAdded
End If
Now with ADO I can't make it work. I don't know which
string connection should I use. The one bellow I toke
from an example in vba help.
Can anyone help me here?
Dim RS As New ADODB.Recordset
Dim strMsg As String
Dim Cnxn As New ADODB.Connection
Dim strCnxn As String
strCnxn = "Provider='sqloledb';Data
Source='MySqlServer';" & _
"Initial Catalog='Northwind';Integrated
Security='SSPI';"
Cnxn.Open strCnxn
strMsg = "bla bla bla"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Field
unknow") = vbNo Then
Response = acDataErrContinue
Else
RS.Open "TipoConcorrentes"
("Field") = NewData
RS.Update
RS.Close
Response = acDataErrAdded
ADO.
I have this code to add a new item to a combo box.
Dim db As DAO.Database
Dim RS As DAO.Recordset
Dim strMsg As String
strMsg = "Bla bla bla"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Field
unknow") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set RS = db.OpenRecordset("Table", dbOpenDynaset)
RS.AddNew
RS.Fields("Field") = NewData
RS.Update
RS.Close
Response = acDataErrAdded
End If
Now with ADO I can't make it work. I don't know which
string connection should I use. The one bellow I toke
from an example in vba help.
Can anyone help me here?
Dim RS As New ADODB.Recordset
Dim strMsg As String
Dim Cnxn As New ADODB.Connection
Dim strCnxn As String
strCnxn = "Provider='sqloledb';Data
Source='MySqlServer';" & _
"Initial Catalog='Northwind';Integrated
Security='SSPI';"
Cnxn.Open strCnxn
strMsg = "bla bla bla"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Field
unknow") = vbNo Then
Response = acDataErrContinue
Else
RS.Open "TipoConcorrentes"
("Field") = NewData
RS.Update
RS.Close
Response = acDataErrAdded