DLookup forms

harrym

New member
Local time
Today, 04:20
Joined
Apr 2, 2011
Messages
10
I have a form for reservation and like to put an dlookup for noShows
I have done this
Private Sub Celular_AfterUpdate()

If (Not IsNull(DLookup("[Celular]", "tblReservations", "[Celular] ='" & Me!Celular & "'"))) Then
DoCmd.OpenReport "rptReservationsNoShow", acViewPreview, , "Celular = '" & Me!Celular & "'"
Else

End If
End Sub
But this works for all reservations which already have some times ago an reservation with the same celPhone number on my tblReservations data base.
Like to get the openReport only for reservation which have "no" in the table text field Show.
 
Hi. What is the Record Source for your Report? You may have to adjust it to include the correct filter. Maybe you could try it this way.

Code:
DoCmd.OpenReport "rptReservationsNoShow", acViewPreview, , "Celular = '" & Me!Celular & "' AND Show=False"
 
I would like if there was never a noshow the report does not open, only if there was a noshow the report should open. from the celular number entry.
 
I would like if there was never a noshow the report does not open, only if there was a noshow the report should open. from the celular number entry.
Not sure what that means because we can't see your database. Here's what I think you could try though:
Code:
If DCount("*","TableName","NoShow=True")>0 Then
    DoCmd.OpenReport...
End If
 
table has the followin fields reservationID, celular, names, date, hour, adults, kids, comments, arrival hour, noshow.
 
on the form frmReservations i have all this fields from the table, and on celular field the dlookup.
 
table has the followin fields reservationID, celular, names, date, hour, adults, kids, comments, arrival hour, noshow.
on the form frmReservations i have all this fields from the table, and on celular field the dlookup.
Assuming noshow is a Yes/No field, what happens if you try:
Code:
If DCount("*","tblReservations","noshow=True AND celular='" & Me.celular & "'") > 0 Then
    DoCmd.OpenReport "rptReservationsNoShow", , , "noshow=True AND celular='" & Me.celular & "'"
End If
 
using DLookup() function, it will Return Null if it does not find anything.
Otherwise It will return Some Value (text or numeric depend on the field
type of your first Parameter).

so on your first post#1, it will never be Null if it number already exists.
Change it to:

Private Sub Celular_AfterUpdate()

If (IsNull(DLookup("[Celular]", "tblReservations", "[Celular] ='" & Me!Celular & "'"))) Then
DoCmd.OpenReport "rptReservationsNoShow", acViewPreview, , "Celular = '" & Me!Celular & "'"
Else

End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom