Call value from table not form

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I am probably overlooking something stupid here but, I need to pull a value
from a table when a form is not open?

Dim InternalEmail As String
InternalEmail = Forms!frmCommitteeEmail!DMEmail

this gives an error if the form frmCommitteeEmail is not already open. I am
pretty sure that is the problem because if I add code to first open the form
it works fine.

Any help here will be appreciated.

Thanks in advance
 
Dave said:
I am probably overlooking something stupid here but, I need to pull a
value from a table when a form is not open?

Dim InternalEmail As String
InternalEmail = Forms!frmCommitteeEmail!DMEmail

this gives an error if the form frmCommitteeEmail is not already
open. I am pretty sure that is the problem because if I add code to
first open the form it works fine.

Any help here will be appreciated.

Thanks in advance

The DLookup() function should do what you want...

DLookup("FieldName", "TableOrQueryName", "Filter Criteria")
 
So I can just replace this:
InternalEmail = Forms!frmCommitteeEmail!DMEmail


with this:
InternalEmail = DLookup("DMEmail", "tblCommitteeEmail", "")

Dave
 
That gave me an error - so I assume I am implmenting it wrong.
any ideas?

Thanks

Dave
 
Dave said:
So I can just replace this:
InternalEmail = Forms!frmCommitteeEmail!DMEmail


with this:
InternalEmail = DLookup("DMEmail", "tblCommitteeEmail", "")

If you need no criteria then just leave that argument out...

InternalEmail = DLookup("DMEmail", "tblCommitteeEmail")
 
Yep I took that argument out and it still did not work.
However (as usual) it was operator error.
That particular table is a "ref" not a "tbl" - so I was calling something
that did not exist.

All is good in the world now.

Thanks much

dave
 

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

Back
Top