dlookup based on field in form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
This is really bugging me.
I have a form with [Closing], [Opening], [Month] and [PrevMonth] on it, all
linked into the same table. When I click a button, I want to copy the
[Closing] from the record in [PrevMonth]. This means if the [Month] is Aug I
put JUL in [PrevMonth] and click to copy JUL's Closing into Aug's Opening.
I'm using
Me.Opening_5 = DLookup("CLOSING_5", "MONTH_END", "Month ='" &
Me.PrevMonth.Value & "")


But it isn't working. Please help!
Thanks
 
When you say it doesn't work, do you get an error? if so, what is the error?

If the value in PrevMonth is text, then the dlookup missing a closing single
quote:
Me.Opening_5 = DLookup("CLOSING_5", "MONTH_END", "[Month] ='" &
Me.PrevMonth.Value & "'")

If the value is numeric, then you need to remove the single quote from the
beginning
Me.Opening_5 = DLookup("CLOSING_5", "MONTH_END", "[Month] =" &
Me.PrevMonth.Value)

Is MONTH_END the name of the table or query
Is CLOSING_5 the name of the field in the table
When using key words in Access you need to put them in square brackets
(Month), it's not recommanded using KeyWords as fields name
 
Thankyou a thousand times!!! It works!
Thanks.

Ofer Cohen said:
When you say it doesn't work, do you get an error? if so, what is the error?

If the value in PrevMonth is text, then the dlookup missing a closing single
quote:
Me.Opening_5 = DLookup("CLOSING_5", "MONTH_END", "[Month] ='" &
Me.PrevMonth.Value & "'")

If the value is numeric, then you need to remove the single quote from the
beginning
Me.Opening_5 = DLookup("CLOSING_5", "MONTH_END", "[Month] =" &
Me.PrevMonth.Value)

Is MONTH_END the name of the table or query
Is CLOSING_5 the name of the field in the table
When using key words in Access you need to put them in square brackets
(Month), it's not recommanded using KeyWords as fields name

--
Good Luck
BS"D


s4 said:
Hi,
This is really bugging me.
I have a form with [Closing], [Opening], [Month] and [PrevMonth] on it, all
linked into the same table. When I click a button, I want to copy the
[Closing] from the record in [PrevMonth]. This means if the [Month] is Aug I
put JUL in [PrevMonth] and click to copy JUL's Closing into Aug's Opening.
I'm using
Me.Opening_5 = DLookup("CLOSING_5", "MONTH_END", "Month ='" &
Me.PrevMonth.Value & "")


But it isn't working. Please help!
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top