Docmd.OpenForm Requires Mutliple Attempts

J

Johnny Meredith

Hi all,

I've created a database (small) that queries another database (huge)
based
on values looked up by the user. The first database creates
a DAO recordset based on data in the second, and then loops through
it and populates a table in the first database.

There is a form in the first database I use to display the results
to the user. It's opened in datasheet mode. When the code
executes the docmd.openform "x" line, it throws an exception.
I click debug, break to this line, and hit play. The second time
it works without problems.

Inserting a doevents line does not fix the problem. Does anyone
have an idea what might be causing this? This database is
extremely simple (it's a one-off for someone), and I'm sure that
I've done this before and never seen any errors like this.

Side note: the user on this computer does not have admin rights.
I'm getting a series of other weird errors that look user-rights
related. I tried to trap this
error (by simply reexecuting the docmd line, and Access went into an
infinite loop. Again, manual reexecution solves the problem.

Both databases are Access 2000
Windows XP Pro Ops.

Thanks,
Johnny
 
B

Bruce M. Thompson

I've created a database (small) that queries another database (huge)
based
on values looked up by the user. The first database creates
a DAO recordset based on data in the second, and then loops through
it and populates a table in the first database.

Can the data returned be represented in a Select query (see the example, below,
for how to connect to the table in the second database file)?

Example:
SELECT * FROM tblName IN "c:\test\MyOtherMDB.mdb";

Of course, you would need to specify only the fields you wanted and apply
criteria to return only the records you needed.
There is a form in the first database I use to display the results
to the user. It's opened in datasheet mode. When the code
executes the docmd.openform "x" line, it throws an exception.
I click debug, break to this line, and hit play. The second time
it works without problems.

If the above approach (using the query) works, simply bind the form on the
Select query. You can set the query's recordset type to "Snapshot" in the
query's property sheet to prevent modifications to the data, if this is to be
read-only.
 

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