|
-
Sep 15th, 2005, 07:02 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] MS Access to SQL Linked tables connection
I am getting the following error on this pretty basic line of code hope someone can help.
Object Variable or With block variable not set
'MS Access VBA Code
VB Code:
Private Sub Form_Load()
Dim rs As Recordset
Dim cnn As Connection
[U]cnn = CurrentProject.Connection[/U]
rs.Open "SELECT * from Employees", cnn, , , adCmdText
Me.lstEmpStates.RowSourceType = ValueList
While Not rs.BOF And Not rs.EOF
'Me.lstEmpStates.Additem
rs.MoveNextWend
End Sub
-
Sep 15th, 2005, 07:25 AM
#2
Re: MS Access to SQL Linked tables connection
Change the line to
VB Code:
set cnn = CurrentProject.Connection
-
Sep 15th, 2005, 07:37 AM
#3
Thread Starter
Frenzied Member
Re: MS Access to SQL Linked tables connection
Thanks that has taken me past that error, I now get the same error on the next line..
rs.Open "SELECT * from Employees", cnn, , , adCmdText
-
Sep 15th, 2005, 08:01 AM
#4
Re: MS Access to SQL Linked tables connection
 Originally Posted by FishGuy
Thanks that has taken me past that error, I now get the same error on the next line..
rs.Open "SELECT * from Employees", cnn, , , adCmdText
The problem is that rs is not an instance of an object yet. Theis can be done with the New keyword when you declare the variableor later by using the Set keyword
-
Sep 15th, 2005, 08:05 AM
#5
Thread Starter
Frenzied Member
Re: MS Access to SQL Linked tables connection
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|