Access Recordset

  • Thread starter Thread starter 文仔
  • Start date Start date
Æ

文仔

When I exe the recordset VBA program the line one was
Dim dbo as Database

the computer show to me was error
Why?
 
Thanks a lot
next problem, was show as follows, please help!!!

Private Sub Command0_Click()
Dim dbo As Database
Dim rst As Recordset
Dim strsql As String

Set dbo = CurrentDb
strsql = "Select *. from table1"
Set rst = dbo.OpenRecordset(strsql)
rst.Sort = "field1 Desc"
rst.Filter = "[field1] like '*y*'"
Set rst = rst.OpenRecordset <-----Show compile error

With rst
.MoveFirst
Do While Not .EOF
Debug.Print ![Field1]
.MoveNext
Loop
.Close
End With
dbo.Close
Set dbobject = Nothing
End Sub
 
Read the same article as to how to handle this ambiguity.

It should give you a Dim idea what to do. :-)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

文仔 said:
Thanks a lot
next problem, was show as follows, please help!!!

Private Sub Command0_Click()
Dim dbo As Database
Dim rst As Recordset
Dim strsql As String

Set dbo = CurrentDb
strsql = "Select *. from table1"
Set rst = dbo.OpenRecordset(strsql)
rst.Sort = "field1 Desc"
rst.Filter = "[field1] like '*y*'"
Set rst = rst.OpenRecordset <-----Show compile error

With rst
.MoveFirst
Do While Not .EOF
Debug.Print ![Field1]
.MoveNext
Loop
.Close
End With
dbo.Close
Set dbobject = Nothing
End Sub




Allen Browne said:
Add a reference to the DAO library appropriate to your version of Access:
http://allenbrowne.com/ser-38.html
 
Hint: look in your code at the OpenRecordset statement that works OK, then
look at the OpenRecordset statement that gives the error... the difference
should be obvious. Really, the volunteers who answer questions here should
not have to give answers that can easily be found in Help, or in the
Intellisense in the code window.

If you are going to write code, or use someone else's code, you need to
learn to debug it. One really good way to determine what's wrong is to
compare what doesn't work against a similar thing that does.

Larry Linson
Microsoft Office Access MVP
 
Back
Top