N
Nancy C
I am using a query to append data to a table. One of the fields to append
gets it value from another table. (2 of the fields are getting their values
from a FORM).
I want to retrieve the FiscalPeriodNumber from tblFiscalCalendar based on
the month from the form AND the year from the form.
I have tried a couple of different "syntax" approaches, but to no avail.
Can anyone suggest the correct syntax for a dlookup within a query?
Here is what I have tried:
MyPeriodNumber=DLookup("[fiscalperiodnumber]", "tblfiscalcalendar",
"[tblfiscalcalendar]![fiscalperiod] = " &
[Forms]![A_fmnuInvCntrl_R]![txtMyMonth] And
"[tblfiscalcalendar]![fiscalyear]= " & [Forms]![A_fmnuInvCntrl_R]![txtMyYear])
I have also tried this:
PerX:
DLookUp("[fiscalperiodnumber]","tblfiscalcalendar","[tblfiscalcalendar]![fiscalperiod]
= " & [TheMonth] And "[tblfiscalcalendar]![fiscalyear]= " & [TheYear])
In this example, the "themonth" and "theyear" are in the query by
referencing the form controls through query parameters.
Both attempts return a 1. It is as if the AND portion is being ignored and
it simply returns the first information from the first record in the fiscal
calendar where the years match. Syntax . . . punctuation is everything, I
guess!
Help! Thanks!
gets it value from another table. (2 of the fields are getting their values
from a FORM).
I want to retrieve the FiscalPeriodNumber from tblFiscalCalendar based on
the month from the form AND the year from the form.
I have tried a couple of different "syntax" approaches, but to no avail.
Can anyone suggest the correct syntax for a dlookup within a query?
Here is what I have tried:
MyPeriodNumber=DLookup("[fiscalperiodnumber]", "tblfiscalcalendar",
"[tblfiscalcalendar]![fiscalperiod] = " &
[Forms]![A_fmnuInvCntrl_R]![txtMyMonth] And
"[tblfiscalcalendar]![fiscalyear]= " & [Forms]![A_fmnuInvCntrl_R]![txtMyYear])
I have also tried this:
PerX:
DLookUp("[fiscalperiodnumber]","tblfiscalcalendar","[tblfiscalcalendar]![fiscalperiod]
= " & [TheMonth] And "[tblfiscalcalendar]![fiscalyear]= " & [TheYear])
In this example, the "themonth" and "theyear" are in the query by
referencing the form controls through query parameters.
Both attempts return a 1. It is as if the AND portion is being ignored and
it simply returns the first information from the first record in the fiscal
calendar where the years match. Syntax . . . punctuation is everything, I
guess!
Help! Thanks!