From: ghetto_banjo on
you could do this:


if IsNull(Dlookup("[ID#]", "tableName", "[ID#] = '" & me.ID & "'"))
then
Msgbox "Not found"
else
Docmd.OpenReport........
end if



From: Duane Hookom on
I think the error message (which you didn't provide) has to do with canceling
the opening of the report. Your error handling must be in the same procedure
that opens the report:

Select Case Err
Case 2501
'ignore
Case Else
' real error handling goes here
End Select

--
Duane Hookom
Microsoft Access MVP


"gsanderson99(a)yahoo.com" wrote:

> On Apr 20, 10:42 am, ghetto_banjo <adam.v...(a)gmail.com> wrote:
> > are you certain that the report's record source is your table (or a
> > query that selects [ID#])? when Access prompts for a value like
> > that, it usually means that the field name is not found in the
> > report's record source.
>
> I confirmed that the report's record source is a table and the ID# is
> the correct field name. However, I found the problem. The ID field in
> the form is a string, so I changed the strCriteria to:
>
> strCriteria = "[ID#] = " & " ' " & Me.ID & " ' "
>
> This worked, except when the ID# does not exist in the table. I added
> a NoData function to the report, but after displaying the "No Record
> Found" message box I created, I get an error message that leads me
> back to the DoCmd, which is:
>
> DoCmd.OpenReport, strReport, acViewPreview, , strCriteria
>
> The NoData function is:
>
> Private Sub Report_NoData(Cancel As Integer)
>
> Cancel = MsgBox("No Record Found", vbInformation, Me.Caption)
>
> End Sub
>
> Any ideas?
>
> Geoff
> .
>
From: gsanderson99 on
On Apr 20, 12:17 pm, ghetto_banjo <adam.v...(a)gmail.com> wrote:
> you could do this:
>
> if IsNull(Dlookup("[ID#]", "tableName", "[ID#] = '" & me.ID & "'"))
> then
>    Msgbox "Not found"
> else
>    Docmd.OpenReport........
> end if

This worked perfectly, thank you!

Geoff
First  |  Prev  | 
Pages: 1 2
Prev: Crosstab vs Flex Grid
Next: api