I have a subform. I need to use a DLookUp function to set the default value of [Grower] on the subform, based on the value of [Farm] in the same record (but earlier in the datasheet). Both farm and grower value are found in Table.
The idea is that the suer types in a farm number and this sets the default value of the [Grower] combo box the the grower for that farm.
I am taking this approach because the default value will be correct 90% of the time, but not always.
There is a problem with the DLookUp expression I am using: -
DLookUp("[Grower]","tblLevyReceiptsDetail","[Farm] =
" & " Forms![Levy Receipts]![sbfLevyReceiptsDetail Label]![Farm]")
(I inserted the line break here just for readability, it's not in the expression)
I don't get an error message, but the default value is not coming through to the [Grower] combo.
My questions are:
1) Is the expression correct?
2) Can I use this method to set the default value for another field in the same record or should I do it with code?
Any advice much appreciated.
Cheers
Mike
The idea is that the suer types in a farm number and this sets the default value of the [Grower] combo box the the grower for that farm.
I am taking this approach because the default value will be correct 90% of the time, but not always.
There is a problem with the DLookUp expression I am using: -
DLookUp("[Grower]","tblLevyReceiptsDetail","[Farm] =
" & " Forms![Levy Receipts]![sbfLevyReceiptsDetail Label]![Farm]")
(I inserted the line break here just for readability, it's not in the expression)
I don't get an error message, but the default value is not coming through to the [Grower] combo.
My questions are:
1) Is the expression correct?
2) Can I use this method to set the default value for another field in the same record or should I do it with code?
Any advice much appreciated.
Cheers
Mike
Last edited: