get table name for field in form based on query

B

BlueWolverine

Hello,

MS ACCESS 2003 on XP PRO.

I have a form (MyForm) that uses MyQuery as its data source. The fields are
largely bound to MyQuery. MyQuery pulls together several MyTableX. (dim X
as int and smile :-D


I want to extract in VBA the name of the table a particular field comes from
on the form. So if on the form, I have a field, called MyFormField, I want
to get its Table name.

bob = me.MyFormField.tableName ' bob as string
and then you get bob = MyTableX whichever it may be.


That's the result I'm hoping for, I am guessing said method does not exist
but does anyone have an idea on how to get this result?

thanks a ton.
 
S

Stuart McCall

BlueWolverine said:
Hello,

MS ACCESS 2003 on XP PRO.

I have a form (MyForm) that uses MyQuery as its data source. The fields
are
largely bound to MyQuery. MyQuery pulls together several MyTableX. (dim
X
as int and smile :-D


I want to extract in VBA the name of the table a particular field comes
from
on the form. So if on the form, I have a field, called MyFormField, I
want
to get its Table name.

bob = me.MyFormField.tableName ' bob as string
and then you get bob = MyTableX whichever it may be.


That's the result I'm hoping for, I am guessing said method does not exist
but does anyone have an idea on how to get this result?

thanks a ton.

bob = me.MyFormField.SourceTable

ought to do it.
 
S

Stuart McCall

Stuart McCall said:
bob = me.MyFormField.SourceTable

ought to do it.

Mistake. It should read:

bob = CurrentDb.QueryDefs!MyQuery!MyFormField.SourceTable

*Warning* this is untested code, but it ought to work. Post back if not.
 

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