Reputation: 120
I'm trying to use dlookup to see if a date is already in a table, the format is correct as I've checked and it inputs it correctly, just can't get it right for DLOOKUP.
Datelookup = DLOOKUP ("[todays_date]", "119_review", "[todays_date] = Format ("" & Me.Combo87 & " " & Me.Combo89 &" 20" & Me.Combo91 & "", medium)")
Combo87 is the day of the month Combo89 is the month Combo91 is the last 2 digits of the year
Upvotes: 0
Views: 108
Reputation: 8508
Try this:
Sub DL()
Dim d As Date
d = DateSerial(Me.Combo91.Value, Me.Combo89.Value, Me.Combo87.Value)
Datelookup = DLookup("[todays_date]", "119_review", "[todays_date] = #" & Format(d, "Medium") & "#")
End Sub
Upvotes: 0
Reputation: 56026
You can use:
Datelookup = DLookup("[todays_date]", "119_review", "[todays_date] = DateSerial(" & Me.Combo91 & ", " & Me.Combo89 & ", " & Me.Combo87 & ")")
where DateLookup will be Null for "not found".
And do rename your controls to something meaningful.
Upvotes: 1