Help with Dfrist()

  • Thread starter Thread starter Alan Fisher
  • Start date Start date
A

Alan Fisher

I keep getting #error retutrned in the text box when I use
this code as the control source .

=DFirst("SchedEntry","tblairspace","[tblairspace].
[missionid]= " & [Forms]![frmPodUpdate]![MissionId])

The problem is with the criteria statement cause it works
without it only I need the returned value using the
criteria. There is no example in MS Help. Thanks
 
I keep getting #error retutrned in the text box when I use
this code as the control source .

=DFirst("SchedEntry","tblairspace","[tblairspace].
[missionid]= " & [Forms]![frmPodUpdate]![MissionId])

The problem is with the criteria statement cause it works
without it only I need the returned value using the
criteria. There is no example in MS Help. Thanks

Is there more than one SchedEntry for the same [MissionID]?

1) If the name of this control is the same as the name of any field
used within it's control source expression, you will ge an #Error.
Change the control name.

2) If the name of the form on which this control is placed is
"frmPopUpdate", you can simplify your expression to:
=DFirst("[SchedEntry]","tblairspace","[missionid]= " & Me![MissionId])

The above assumes [MissionID] is a Number datatype.

3) DFirst and DLast, give inconsistent returns.
In Access there is no First or Last record, other than as determned in
some specific sorting order. So depending upon the sorting of the
records, you will get inconsistent results.
You would do better to use DMin instead.
Assuming [MissionID] was a Number datatype:
=DMin("[SchedEntry]","tblairspace"," [missionid]= " & Me![MissionId])

The above should return the earliest [SchedEntry] from the table where
the [MissionID] matched the [MissionID] on the form.
 
Back
Top