simoncpage
Programmer
I am trying to connection information from a userform to an access database. I have tried using the following code but I keep getting an error that it cannot open the database? I am sure I have missed something trivial can anyone help?
any help or examples that anyone knows of this type would be great!
Simon
----------------------------------------
Sub ADOFrmSetup()
Dim cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
cn.ConnectionString = "c:\temp\db1.mdb"
cn.Open
Rs.Open "SELECT * FROM ADDRESSES", cn, _ CursorType:=adOpenStatic, _
LockType:=adLockReadOnly
Frm.Textbox1.value = Rs.Fields("First name"Rs.Close
cn.Close
Set RS = Nothing
Frm.Show
End Sub
any help or examples that anyone knows of this type would be great!
Simon
----------------------------------------
Sub ADOFrmSetup()
Dim cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
cn.ConnectionString = "c:\temp\db1.mdb"
cn.Open
Rs.Open "SELECT * FROM ADDRESSES", cn, _ CursorType:=adOpenStatic, _
LockType:=adLockReadOnly
Frm.Textbox1.value = Rs.Fields("First name"Rs.Close
cn.Close
Set RS = Nothing
Frm.Show
End Sub