Default Value Property Subquery

kilobyte

Registered User.
Local time
Today, 13:55
Joined
Oct 5, 2005
Messages
52
Is it possible to use a subquery as a default value property setting?


I need to use a value from a table that is not the focus table of the form, I have tried to identify it with a subquery but it returns a #name? error every time. I hate those!

Any help would be appreciated.
 
Thanks for responding, I have tried to reference it the best I can, but I really think that is exactly what the problem is.

As far as I have seen, I have never seen a [Thing]![Stuff]![Doohicky] kind of identifier referring to a field in a table or query. Is that even possible? Like:

[Tables]![tblRptDt]![ReportingPeriod]

Or

[Queries]![qryCalLastRptDt]![LastReportDate]

Or anything like that. I have only seen forms referenced this way. Is it possible to identify fields like this?

The way that I have seen done is with a subquery. I used a subquery like this as a criteria.

In (select LastReportDate from qryCalLastRptDt)

A subquery like this one returns with a #name? error. I thought perhaps the problem was using an entire query so I made it a select TOP 1 query but it still didn't work.

So what the heck IS the propber syntax for referencing fields anyway?
 
If the field is not part of an underlying query/table of your form or one of it's SubForms or another loaded form then you will need to retrieve the data some other way. You could use a DLookup or a Select SQL in the OnLoad event of the form perhaps.
 
Dlookup was the piece of the puzzle I was missing. I looked that thing up and it works like a charm. Thanks for your help!

I hear that Dlookup is unpopular. Why is that?
 
All of the Domain functions are slower than doing it yourself with DAO. They are each basically a wizard of a sort and simply make things easier for the programmer. However, used with discretion they are effective and simple with little penalty to pay for their speed.
 

Users who are viewing this thread

Back
Top Bottom