Solved DLookup with ComboBox Variable (1 Viewer)

Malcolm17

Member
Local time
Today, 06:19
Joined
Jun 11, 2018
Messages
107
Hey,

I have a form which I am looking to select from a list and display information from a table in to a textbox using DLookup. So I need the control source DLookup to be something like the following:

= DLookup ( txtDiaryFeed , tbl_Net_Diary , TheDate = txtLocalSystemDate)

I just cannot see where I am going wrong, please can you have a look,

Thanks,

Malcolm

Fields are:
cbxDiaryList (actual FieldName translates in to the field txtDiaryFeed)
txtDiaryFeed (the name of the Field in the Table) - on a subform (subfrmHome)
txtDiary (where the text will be displayed) - on a subform (subfrmHome)
txtLocalSystemDate - on the main form (frmBackground), can be any date over a number of years
Table is called tbl_Net_Diary


Amongst many other things I have tried is:

=DLookUp([txtDiaryFeed],[tbl_Net_Diary],&[TheDate]=Forms![frmBackground]![txtLocalSystemDate]&)

=DLookUp([Forms].[frmBackground]![subfrmHome]![txtDiaryFeed],[tbl_Net_Diary])

= DLookup("[txtDiaryFeed]", "[tbl_Net_Diary]" , "[TheDate] ='" & Forms![frmBackground]![txtLocalSystemDate] & "'")

=DLookUp([Forms].[frmBackground]![subfrmHome]![txtDiaryFeed],[tbl_Net_Diary],&[TheDate]=Forms![frmBackground]![txtLocalSystemDate]&)

=DLookUp("[Forms].[frmBackground]![subfrmHome]![txtDiaryFeed]","[tbl_Net_Diary]","&[TheDate]=Forms![frmBackground]![txtLocalSystemDate]&")

=DLookUp("[Forms].[frmBackground]![subfrmHome]![txtDiaryFeed]","[tbl_Net_Diary]","&[TheDate]=14/02/2021&")

=DLookUp("[Forms].[frmBackground]![subfrmHome]![txtDiaryFeed]","[tbl_Net_Diary]","&14/02/2021 = [TheDate]&")

=DLookUp("[Forms].[frmBackground]![subfrmHome]![txtDiaryFeed]","[tbl_Net_Diary]","' [TheDate] = 14/02/2021'")
 

moke123

AWF VIP
Local time
Today, 02:19
Joined
Jan 11, 2013
Messages
3,852
I believe you'd need to delimit the date field.
Your code should look like below but I'm a little confused as to the paths of your forms ( whether you can use me keyword or not)
Code:
= DLookup ( "txtDiaryFeed" ,"tbl_Net_Diary" , "TheDate = #" &  [Your date field here] & "#")
 

Malcolm17

Member
Local time
Today, 06:19
Joined
Jun 11, 2018
Messages
107
Hey Moke123,

I got that to work for the dates, however when I select the Department from my ComboBox list it just pulls through the Field Name which is displayed in my textbox txtDiaryFeed, can you help with this please?

Code:
=DLookUp(" [forms]![frmbackground]![subfrmhome]![txtdiaryfeed] ","tbl_Net_Diary","TheDate = #" & [Forms]![frmBackground]![txtLocalSystemDate] & "#")

Thanks, Malcolm
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:19
Joined
May 7, 2009
Messages
19,169
Code:
=DLookUp("[" & [forms]![frmbackground]![subfrmhome]![txtdiaryfeed] & "]","tbl_Net_Diary","TheDate = #" & [Forms]![frmBackground]![txtLocalSystemDate] & "#")
 

Users who are viewing this thread

Top Bottom