I have spent the last two days trying to figure this out...I have no previous knowledge of Visual Basic 6 (I am using what came with Office, which is Visual Basic 6.3).
I am using Word 2003 and Access 2000 (I also have Access 97 if need be).
Now I have read about ADO, DAO, ODBC and ADODB, DSN and DSN-less connections or SOMETHING along those lines and to be honest I am a little lost.
I have tried many different simple examples of code, but none seem to work. I usually end up with an error message saying that the Object was not defined, for which case I read that the solution is to check the References library and make sure the appropriate Reference is checked, which I did.
Here is an example of code...is there anything wrong with it:
Sub DBConnect() Dim Cmd As New ADODB.Command Dim sqlString As String Dim RS As ADODB.Recordset Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Template\evaluations.mdb" Conn.Open sqlString = "SELECT * FROM data2" Cmd.CommandText = sqlString Cmd.CommandType = adCmdText Set RS = Cmd.Execute End SubThe error message I get for that is Run-time error '424': Object required.
I've tried commenting out some of the code, leaving only the first 3 lines, and I do not get any errors...but as soon as I uncomment the 4th line, I get that error.
Does anyone know how to make a simple connection from Word to Access and pull out certain results? Where have I gone wrong, what am I missing? Again, I have no previous experience with VB6 and would appreciate any and all help.
Thanks,
Tirus
Edited by Tirus, 09 June 2008 - 09:06 PM.