treeview issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Make sure you have a reference to Microsoft DAO 3.x Object Library.

Open a module | Tools | References

HTH,
Josh
 
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.)
 
Back
Top