Petr Danes
Registered User.
- Local time
- Today, 06:24
- Joined
- Aug 4, 2010
- Messages
- 150
Tried this a while back in AccessForums.net (https://www.accessforums.net/showthread.php?t=84803). Got several suggestions, but no solution or explanation, and the problem continues.
========================
I believe this has started since I switched to 365 - I don't recall it happening in 2007, although I 'm not absolutely certain. If it did happen before, it is certainly happening much more now, but development is ongoing, so it may be that I have just generated some new errors.
I have an unbound form with a single record, filled by VBA, containing a subform, with recordset bound to an ODBC-linked query calling various MSSQL stored procedures with various parameters. I modify the text of the query as needed and requery the subform. Not sure if that is relevant, since that is not new, but I'm trying to include as many possibly pertinent details as possible.
What is happening is that I sometimes need to find out how many records I have in the subform's recordset. The tests are for 0, 1, 4 or > user-set value. The code handling the results works, but the comparison bombs at seemingly random intervals, and I have so far been unable to pinpoint what combination of circumstances might be affecting it.
The main form is Akces, the subform is Podrobnosti, the subform's container on the main form is sfPodrobnosti.
A statement of the form:
will sometimes work and sometimes not. When it does not, it throws an error saying that the object does not exist. But all the objects do exist. Printing the names, and ... Is Nothing tests all show that the object does exist, and besides that, the form and subform are both loaded and the record(s) displayed.
However, when I modify the code to:
it works fine. Except that I cannot use the RecordsetClone object to manipulate the actual recordset, so I cannot move from record to record under program control, which one of my graphic gimmicks does.
Does this make any sense to any one?
How can a reference to such an object throw an error, when the object very clearly exists?
How can an object 'not exist' and yet its clone be fine?
Why would the same statement sometimes work and sometimes not?
Some of this is happening in class modules, some directly in the form's code module.
========================
I believe this has started since I switched to 365 - I don't recall it happening in 2007, although I 'm not absolutely certain. If it did happen before, it is certainly happening much more now, but development is ongoing, so it may be that I have just generated some new errors.
I have an unbound form with a single record, filled by VBA, containing a subform, with recordset bound to an ODBC-linked query calling various MSSQL stored procedures with various parameters. I modify the text of the query as needed and requery the subform. Not sure if that is relevant, since that is not new, but I'm trying to include as many possibly pertinent details as possible.
What is happening is that I sometimes need to find out how many records I have in the subform's recordset. The tests are for 0, 1, 4 or > user-set value. The code handling the results works, but the comparison bombs at seemingly random intervals, and I have so far been unable to pinpoint what combination of circumstances might be affecting it.
The main form is Akces, the subform is Podrobnosti, the subform's container on the main form is sfPodrobnosti.
A statement of the form:
Code:
i = Val(Form_Akces.sfPodrobnosti.Form.Recordset.RecordCount)
However, when I modify the code to:
Code:
i = Val(Form_Akces.sfPodrobnosti.Form.RecordsetClone.RecordCount)
Does this make any sense to any one?
How can a reference to such an object throw an error, when the object very clearly exists?
How can an object 'not exist' and yet its clone be fine?
Why would the same statement sometimes work and sometimes not?
Some of this is happening in class modules, some directly in the form's code module.