dlookup into unbound textbox pull all of same date (1 Viewer)

murray83

Games Collector
Local time
Today, 22:14
Joined
Mar 31, 2017
Messages
728
not sure if this is correct area but i believe its a vba question

i have form with unbound textboxs with dlookup like so
Code:
=DLookUp("[AM Shift]","[SYS]","[AM When] = [SYSDateAM] ")

but on the table different users are able to add to it which creates new record but my dlookup only seems to pull the first one

what code do i require to pull the second third etc i tried putting & that just duplicated the first record also tried + this didn't work full stop

cheers :)
 

Attachments

  • table.png
    table.png
    19.8 KB · Views: 79
  • form.png
    form.png
    8.2 KB · Views: 70

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:14
Joined
May 7, 2009
Messages
19,237
before anything, backup your main form.
remove your unbound textboxes
create a Continuous Form again table SYS.
add this continuous form as a subform to
your main form.

on the subform Property->Data:

Link Master Fields: [SYSDateAM]
Link Child Fields: [AM WHEN]

you will now be able to see
only records for a particular
SYSDateAM, if there are.
 

Mark_

Longboard on the internet
Local time
Today, 14:14
Joined
Sep 12, 2017
Messages
2,111
@Murray,

DLookup returns a SINGLE record, not all. From what you have shown, it is working properly. DLookup will return NULL if there is no matching record, something else to be careful with.
 

murray83

Games Collector
Local time
Today, 22:14
Joined
Mar 31, 2017
Messages
728
@Murray,

DLookup returns a SINGLE record, not all. From what you have shown, it is working properly. DLookup will return NULL if there is no matching record, something else to be careful with.

cheers so what i take from this, there is NO way to just show data for the whole date when there a more than one record with same date into a textbox
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 16:14
Joined
Feb 28, 2001
Messages
27,175
Specifically, no reasonable way with a simple textbox to show multiple values.

You can populate a subform (in continuous mode) or there are some other things involving combo boxes or list boxes - but both of those latter solutions have limits on utility. But no, there is no simple-minded way to feed multiples to a text box.

Arnel addressed the continuous subform solution so I'll leave that alone.

Mark_ has absolutely correctly pointed out that DLOOKUP is single-valued.

What's left is to iterate through a recordset based on a given date. How you display that depends on lots of factors including how many of those things you could expect to see. But basically, anything big enough to hold your list (and yet still be a simple, unbound text box) has to be fed through a loop over a qualified recordset with string concatenation and heavy-duty formatting.
 

murray83

Games Collector
Local time
Today, 22:14
Joined
Mar 31, 2017
Messages
728
before anything, backup your main form.
remove your unbound textboxes
create a Continuous Form again table SYS.
add this continuous form as a subform to
your main form.

on the subform Property->Data:

Link Master Fields: [SYSDateAM]
Link Child Fields: [AM WHEN]

you will now be able to see
only records for a particular
SYSDateAM, if there are.

worked a treat many thanks for all help
 

Users who are viewing this thread

Top Bottom