accessing table in application from library

J

jfp

I am moving code from an app into a library prior to delivery of the app
and have now encountered this problem.

In the app there is a table (call it "VP")
From the app i launch a form in the library.
As part of the Open procedure for the form, i set the recordsourcetype
for a list box to "Table/Query" and i set the recordsource to a simple
query on table VP ("Select [VP].field1, ...)

When this form was in the app (prior to moving stuff into the library)
this worked fine. With the form in the library, the listbox comes up
empty. If i set a breakpoint, get into the immediate window, and attempt
a Requery on the listbox, i get an error that the table does not exist.
However -- if in the same part of the code i add this:
MsgBox "VP has " & NRecords("VP")
(here, NRecords is a simple function in the library that returns the #
of records in a table) i get a messagebox with the correct answer.
SO --
1) code on the form in the library can access the table in the app,
2) a listbox on the form in the library cannot.
Does this make sense -- or am i doing something wrong ?
 
P

Paul Overway

The table must exist in the library. One workaround is to create a link to
the table in your main app (or if the table in the main app is linked, then
you'd want the same link in your library).
 
J

jfp

see end ...
I am moving code from an app into a library prior to delivery of the app
and have now encountered this problem.

In the app there is a table (call it "VP")
From the app i launch a form in the library.
As part of the Open procedure for the form, i set the recordsourcetype
for a list box to "Table/Query" and i set the recordsource to a simple
query on table VP ("Select [VP].field1, ...)

When this form was in the app (prior to moving stuff into the library)
this worked fine. With the form in the library, the listbox comes up
empty. If i set a breakpoint, get into the immediate window, and attempt
a Requery on the listbox, i get an error that the table does not exist.
However -- if in the same part of the code i add this:
MsgBox "VP has " & NRecords("VP")
(here, NRecords is a simple function in the library that returns the #
of records in a table) i get a messagebox with the correct answer.
SO --
1) code on the form in the library can access the table in the app,
2) a listbox on the form in the library cannot.
Does this make sense -- or am i doing something wrong ?
-=-=
I am trying this as a work around:
The form in the library cannot seem to have a listbox with recordsource
coming from a table in the app. SO, i want to take the query that would
normally be used as recordsource and execute it as a make-table query
(Select ... Into Temp_Table From ...) and then base the list box on that
table. The first half of this works -- the query has no problem finding
the table in the app -- but the temp table that gets made also goes into
the app database, which leaves me with the same problem -- the listbox
in the library database cannot see it. How do i get this table to go
into the library, not the app, database? (Or, if it must go into the
app, can i then copy it into the library?)
 
P

Paul Overway

Just thought of a better work-around. Your SQL for the recordsource should
look like this:

SELECT * FROM tblSomeTable IN 'C:\some.mdb'


--
Paul Overway
Logico Solutions, LLC
www.logico-solutions.com


jfp said:
see end ...
I am moving code from an app into a library prior to delivery of the app
and have now encountered this problem.

In the app there is a table (call it "VP")
From the app i launch a form in the library.
As part of the Open procedure for the form, i set the recordsourcetype
for a list box to "Table/Query" and i set the recordsource to a simple
query on table VP ("Select [VP].field1, ...)

When this form was in the app (prior to moving stuff into the library)
this worked fine. With the form in the library, the listbox comes up
empty. If i set a breakpoint, get into the immediate window, and attempt
a Requery on the listbox, i get an error that the table does not exist.
However -- if in the same part of the code i add this:
MsgBox "VP has " & NRecords("VP")
(here, NRecords is a simple function in the library that returns the #
of records in a table) i get a messagebox with the correct answer.
SO --
1) code on the form in the library can access the table in the app,
2) a listbox on the form in the library cannot.
Does this make sense -- or am i doing something wrong ?
-=-=
I am trying this as a work around:
The form in the library cannot seem to have a listbox with recordsource
coming from a table in the app. SO, i want to take the query that would
normally be used as recordsource and execute it as a make-table query
(Select ... Into Temp_Table From ...) and then base the list box on that
table. The first half of this works -- the query has no problem finding
the table in the app -- but the temp table that gets made also goes into
the app database, which leaves me with the same problem -- the listbox
in the library database cannot see it. How do i get this table to go
into the library, not the app, database? (Or, if it must go into the
app, can i then copy it into the library?)
 

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