Hi,
I have an unbound control on my main form where I type a date. This should produce a search on table data between 2 dates which would then populate another control on the same form with a file reference (a box file number).
My table is "tblPYTRUN" and has fields:
"FILE REF:" (datatype Number) - this is a file number
"INCLUDES:" (datatype Short Date) - a starting date for the box file
"to" (datatype Short Date) - the final date in the box file
My form is "frmMAIN" and has these controls:
"txtPytRunSearch" (Unbound) - I would type a date here.
"txtPytRunBoxNo" with the following control source:
=DLookUp("[FILE REF:]","tblPYTRUN",[Forms]![frmMAIN]![txtPytRunSearch] & " Between [tblPYTRUN]![INCLUDES:] And [to]")
I had a similar problem before with another table, and it worked thanks to this forum. However, only numbers were involved.
This time though, when I type a date into "txtPytRunSearch" (tried various formats), nothing is appearing in the "txtPytRunBoxNo" box. Why I'm not sure. I thought of changing the format of "txtPytRunSearch" to Short Date, but this didn't help.
Is the dlookup code wrong ? - does it need to be re-worded when dealing with 'Between' and 'Dates'
Regards.
I have an unbound control on my main form where I type a date. This should produce a search on table data between 2 dates which would then populate another control on the same form with a file reference (a box file number).
My table is "tblPYTRUN" and has fields:
"FILE REF:" (datatype Number) - this is a file number
"INCLUDES:" (datatype Short Date) - a starting date for the box file
"to" (datatype Short Date) - the final date in the box file
My form is "frmMAIN" and has these controls:
"txtPytRunSearch" (Unbound) - I would type a date here.
"txtPytRunBoxNo" with the following control source:
=DLookUp("[FILE REF:]","tblPYTRUN",[Forms]![frmMAIN]![txtPytRunSearch] & " Between [tblPYTRUN]![INCLUDES:] And [to]")
I had a similar problem before with another table, and it worked thanks to this forum. However, only numbers were involved.
This time though, when I type a date into "txtPytRunSearch" (tried various formats), nothing is appearing in the "txtPytRunBoxNo" box. Why I'm not sure. I thought of changing the format of "txtPytRunSearch" to Short Date, but this didn't help.
Is the dlookup code wrong ? - does it need to be re-worded when dealing with 'Between' and 'Dates'
Regards.