treeview issue

T

tope12

I went through the filling a treeview recursively example and it worked. When
i try to apply the load event part of the code, it gives me an "user defined
type not defined message at the third line of the code.

Private Sub Form_Load()
Const strTableQueryName = "new by can query"
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset(strTableQueryName, dbOpenDynaset, dbReadOnly)
AddBranch rst:=rst, strPointerField:="REFNUM", strIDField:="ONUM",
strTextField:="PName"
End Sub
 
D

Duncan Bachen

tope12 said:
I went through the filling a treeview recursively example and it worked. When
i try to apply the load event part of the code, it gives me an "user defined
type not defined message at the third line of the code.

Private Sub Form_Load()
Const strTableQueryName = "new by can query"

Think about a better naming convention here! This would be much easier
to read as qryByCan.

Read up on using object prefixes and Leszynski/Reddick naming
conventions. Avoid using spaces in your object names whenever you can.
Check out Tony's article at
http://www.granite.ab.ca/access/tablefieldnaming.htm, which includes
some links at the bottom in regards to naming conventions and database
design. Personally I don't use field level prefixes like he does, but
that's a matter of preference.

Dim db As DAO.Database, rst As DAO.Recordset

Break this into two lines

Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset(strTableQueryName, dbOpenDynaset, dbReadOnly)
AddBranch rst:=rst, strPointerField:="REFNUM", strIDField:="ONUM",
strTextField:="PName"

Make sure to explicitly close your recordset to prevent memory leaks

rst.close
Set rst = Nothing
 
J

Joshua A. Booker

Make sure you have a reference to Microsoft DAO 3.x Object Library.

Open a module | Tools | References

HTH,
Josh
 
D

Douglas J Steele

Sounds as though you don't have a reference set to DAO.

With any code module open, select Tools | References from the menu bar.
Scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, select it, and back out of the dialog.

(I'm assuming you're using Access 2000 or Access 2002.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top