Problem setting rowsource in Access 2003

G

gardner.bob

I have code which runs on several versions af Access with no problems
but crashes in Access 2003. What I am doing is setting the RowSource
property of a list box to one of two different queries based on certain
criteria. This is in the forms OnOpen event. One of the queries
happens to be the default property in the list box RowSource property.

This has worked fine until it was run on Access 2003. If the code
attempts to set the RowSource to the same value as the default, I get
an applicatiion error - the kind where they want to send a report to
Microsoft. If I comment out the offending line or blank out the
property in the property box, then 2003 works fine.

Here's the offending line if that makes a difference:

Me.lstLastNameBox.RowSource = "qryLastNameQuery"

Should I have to do this? Has anyone seen this before?

Thanks,
Bob
 
W

Wayne Morgan

In case it is a timing issue, try your code in the form's Load event instead
of the Open event.
 
G

gardner.bob

Well I tried your idea and that worked the same as when I deleted the
RowSource property for the List Box. I'm not sure I understand why it
works in the Load event but not in the Open event and only in Access
2003.

Maybe we are just not meant to understand.

Thanks,

Bob
 
W

Wayne Morgan

The form's recordset isn't available until the Load event. There may have
been something that the earlier versions were more forgiving of than 2003.
 
Top