Doubleclick on a treeview node - sometimes it works and sometimes not

V

Volker Neurath

Hello,

today I had a problem with my small database that is driving me nut, because
I don't see any logical reason for this behaviour:

I have a treeview in the footer of my form. It's task is to show the
dependencies between the quotations (the DB stores information about
quotations) i.e. which was the first q. of a project, how many quotations
are there for this project and so on.
When I do a doubleclick on one of the nodes the data of the corresponding
quotation should be shown.

Ok, all this I solved yesterday, I tested and it worked - or it seemed to
work.

Today morning:

I started my main form, pressed a button and => an error occurred.
I wondrered, pressed another button =>error.
A few minutes later I was sure: nothing worked.

Test in my development-database ==> it allworks fine.

Another three quarters of an hour later I kew why and solved it:
The productive database had lost one required reference - for what reason
ever...

Ok, at least, all main functions work but:

the doubleclick on the treeview nodes behave strange - on the first
recordset it works fine and opens the related recordset. but when I
navigate to the forth or fith set, and try again, access insists in not
finding a property of a control (but why does it find it, when i try the
first recordset?).

This ist the code, thrown on Node-Doubleclick:
--------
Private Sub tvwHistoryTree_DblClick()
Dim lst As String
Dim sql As String
Dim quot As Long


lst = "lngQuotationNr"

quot = objTreeview.SelectedItem

sql = BuildCriteria(lst, dbLong, quot)

Me.Filter = sql
Me.FilterOn = True
Me!cmdHistoryFilterEnde.Enabled = True

objTreeview.Nodes.Clear

Call FillHistoryTree(Me!txtMasterQuotation, 0) <-- this line causes the
error!

End Sub
---------

some further tests have shown that Access cannot find the .value property of
txtMasterQuotation, but why?

And why can't Access find IT, when I run the code on a record set in the
tables "middle", but can, when the code is run on the very first recordset?


Last but not least, here's the code of FillHistoryTree:
-----------
Private Sub FillHistoryTree(lngMaster As Long, lngVorgaenger As Long)
Dim db As DAO.Database
Dim rst As DAO.Recordset

Dim objNode As MSComctlLib.node

Set db = CurrentDb

If lngMaster = 0 Then Exit Sub

If lngVorgaenger = 0 Then
Set rst = db.OpenRecordset("SELECT lngQuotationNr,
lngMasterQuot, lngVorgNum " _
& "FROM tblQuotMaster " _
& "WHERE lngMasterQuot = " & Me!txtMasterQuotation & "
AND lngVorgNum = 0;")
Else
Set rst = db.OpenRecordset("SELECT lngQuotationNr,
lngMasterQuot, lngVorgNum " _
& "FROM tblQuotMaster " _
& "WHERE lngMasterQuot = " & Me!txtMasterQuotation _
& " AND lngVorgNum = " & lngVorgaenger & ";")
End If

Do While Not rst.EOF
If lngVorgaenger = 0 Then
Set objNode = objTreeview.Nodes.Add(, , "Q" &
rst!lngQuotationNr, rst!lngQuotationNr)
Else
Set objNode = objTreeview.Nodes.Add("Q" & lngVorgaenger,
tvwChild, "Q" & rst!lngQuotationNr, rst!lngQuotationNr)
End If

Call FillHistoryTree(lngMaster, rst!lngQuotationNr)

rst.MoveNext

Loop

Set objNode = Nothing

rst.Close
Set rst = Nothing
Set db = Nothing

End Sub


Anybody out here, who can give me a hint?

And: isit possible, that the reason for this mystery is the fact, that I do
not run a local Access installation but work on a Citrix Remote Server
which is, in fact, a server*farm* and we cannot influence or guess which
server we connect with?

Volker
 
V

Volker Neurath

Hello @ll,

during the last 4 days I tested my form on my own and found the
following
This ist the code, thrown on Node-Doubleclick:
--------
Private Sub tvwHistoryTree_DblClick()
Dim lst As String
Dim sql As String
Dim quot As Long

lst = "lngQuotationNr"
quot = objTreeview.SelectedItem
sql = BuildCriteria(lst, dbLong, quot)

up to here, the .Value-property of Me!txtMasterQuotation can be found
Me.Filter = sql
Me.FilterOn = True
Me!cmdHistoryFilterEnde.Enabled = True

but from here, after the Filter has been activated, it can't and causes
a runtime-error.

But: I can't figure out, why.

Even deactivating the only procedure that was run in form_current didn't
change this strange behaviour.

Anybody out there with a hint for me?

Volker
 
V

Volker Neurath

Hi Michael,

Michael said:
maybe try quot = objTreeView.SelectedItem.Text


I've allready tried this.

Actually I discussed the same problem in the german group too, and two
posters there have tested a sample database I presented for download:

http://home.telebel.de/voneura/docs/history-testDb.mdb

Start the form and fill the treeeview by pressing the "history" Button.
Then expand the tree and double-click the first subnode => works.

Disable the Filter by Pressing the Botton "History Filter Aus"
Then change to the Recordset wicht shov end-numers 3063 (must be the 4th
IIRC), and try again => fails.

One fello in the german group could reproduce this too and found no
explanation - only ways for getting around.

Volker
 
M

Michael Gramelspacher

Hi Michael,




I've allready tried this.

Actually I discussed the same problem in the german group too, and two
posters there have tested a sample database I presented for download:

http://home.telebel.de/voneura/docs/history-testDb.mdb

Start the form and fill the treeeview by pressing the "history" Button.
Then expand the tree and double-click the first subnode => works.

Disable the Filter by Pressing the Botton "History Filter Aus"
Then change to the Recordset wicht shov end-numers 3063 (must be the 4th
IIRC), and try again => fails.

One fello in the german group could reproduce this too and found no
explanation - only ways for getting around.

Volker

I do not know what is causing the error. After the filter is applied, the values of the fields
returns Null. One can plainly see that the fields contain the filtered values.

If you do the filtering manually using the toolbar icons, everything works correctly. It does not
seem to be a Treeview problem. The problem is getting the textbox control values after the filter
has been applied.

Maybe someone else has ideas about this.
 
V

Volker Neurath

Michael said:
I do not know what is causing the error.

So you're very well in common with the guys in the german group ;)
After the filter is applied, the
values of the fields returns Null. One can plainly see that the fields
contain the filtered values.

The problem is, that Me!txtMaster Quotation.Value isn't accessible any
longer after the filter has been applied.
If you do the filtering manually using the toolbar icons, everything works
correctly. It does not seem to be a Treeview problem.
The problem is getting the textbox control
values after the filter has been applied.

Exactly.

Because of the fact that this problem won't occur if, instead of applying a
filter, form.recordsource is changed, i will think about changing
my "filtering" into this way.

Volker
 
M

Michael Gramelspacher

So you're very well in common with the guys in the german group ;)


The problem is, that Me!txtMaster Quotation.Value isn't accessible any
longer after the filter has been applied.


Exactly.

Because of the fact that this problem won't occur if, instead of applying a
filter, form.recordsource is changed, i will think about changing
my "filtering" into this way.

Volker

Here are two things to try, but I am not sure I really undertand the overall idea.

Private Sub FillHistoryTree(lngMaster As Long, lngVorgaenger As Long)
Dim db As DAO.Database
Dim rst As DAO.Recordset

Dim objNode As MSComctlLib.node
Dim s As String


Set db = CurrentDb

If lngMaster = 0 Then Exit Sub

If lngVorgaenger = 0 Then
s = "SELECT lngQuotationNr, lngMasterQuot, lngVorgNum " _
& "FROM tblQuotMaster " _
& "WHERE lngMasterQuot = " & lngMaster & " AND lngVorgNum = 0;"
'MsgBox s 'for testing only
Set rst = db.OpenRecordset(s)
Else
s = "SELECT lngQuotationNr, lngMasterQuot, lngVorgNum " _
& "FROM tblQuotMaster " _
& "WHERE lngMasterQuot = " & lngMaster _
& " AND lngVorgNum = " & lngVorgaenger & ";"
'MsgBox s 'for testing only
Set rst = db.OpenRecordset(s)
End If

Do While Not rst.EOF
If lngVorgaenger = 0 Then
Set objNode = objTreeview.Nodes.Add(, , "Q" & rst!lngQuotationNr, rst!lngQuotationNr)
Else
Set objNode = objTreeview.Nodes.Add("Q" & lngVorgaenger, tvwChild, "Q" &
rst!lngQuotationNr, rst!lngQuotationNr)
End If

objNode.Selected = True

Debug.Print rst!lngQuotationNr
Call FillHistoryTree(lngMaster, rst!lngQuotationNr)

rst.MoveNext

Loop

objTreeview.Nodes(1).Selected = True
objTreeview.SelectedItem.Expanded = True

Set objNode = Nothing

rst.Close
Set rst = Nothing
Set db = Nothing

End Sub

Private Sub tvwHistoryTree_DblClick()
Dim lst As String
Dim sql As String
Dim quot As Long
Dim l As Long

lst = "lngQuotationNr"

quot = objTreeview.SelectedItem

sql = BuildCriteria(lst, dbLong, quot)

l = Nz(DLookup("lngMasterQuot", "tblQuotMaster", sql), 0)

Me.Filter = sql
Me.FilterOn = True

objTreeview.Nodes.Clear
Call FillHistoryTree(l, 0)

End Sub
 
V

Volker Neurath

Hi @ll,

I just want to give a short feedback.

I took the treeview from the tab-control and placed it into the form's
footer; in addition I changed over from setting a form filter by code, to
directly changing the forms recordsource.
Result: it works without problems.

seems as if the treeview causes problems:
- when it is used in combination with a form-filter and it filters the form
it is placed on
- when it is placed on a tab-control
- any combination of both above

Volker
 
M

Michael Gramelspacher

Hi @ll,

I just want to give a short feedback.

I took the treeview from the tab-control and placed it into the form's
footer; in addition I changed over from setting a form filter by code, to
directly changing the forms recordsource.
Result: it works without problems.

seems as if the treeview causes problems:
- when it is used in combination with a form-filter and it filters the form
it is placed on
- when it is placed on a tab-control
- any combination of both above

Volker

I think changing the form's recordsource is a good way to go. When you filter a form, it usually
means the form has pulled in a lot of records, which now are to be filtered. Maybe just open the
form showing no records, have a way to select criteria, example, comboboxes, and then change the
form's recordsource per the criteria. It seems quite simple.
 

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