472,794 Members | 3,648 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,794 software developers and data experts.

Query returned no results-how to display in form not pop-up msg box

kev
Hi Folks,

I have created a search query in which it successfully returns correct
results. When there are no records returned, instead of giving out a
blank form i created a pop-up msg which is attached to the On Open
event.
However, right after the msg box pops saying"no records", this is
followed by another msg box with "TheOpen Form action was cancelled".

Is there a way i can eliminate the second msg box from appearing?

Or is there another approach in which i want a form to display the
message someting like below:

Your search on (search criteria) returned no results.
what i need is something like when there is matching records, open form
"a" and if there is no records open form"b" stating Your search on
(search criteria) returned no results.
Pls help.

Thanks.

Jan 17 '07 #1
2 3101


On Jan 17, 1:58 am, "kev" <kevi....@gmail.comwrote:
Hi Folks,

I have created a search query in which it successfully returns correct
results. When there are no records returned, instead of giving out a
blank form i created a pop-up msg which is attached to the On Open
event.
However, right after the msg box pops saying"no records", this is
followed by another msg box with "TheOpen Form action was cancelled".

Is there a way i can eliminate the second msg box from appearing?

Or is there another approach in which i want a form to display the
message someting like below:

Your search on (search criteria) returned no results.

what i need is something like when there is matching records, open form
"a" and if there is no records open form"b" stating Your search on
(search criteria) returned no results.

Pls help.

Thanks.
In the code module that calls the open form a, you need to trape for
error 2501 and resume next. (Error 2501 is "The Open Form event was
cancelled")

Jan 17 '07 #2
kev
Hi,

i am not sure on how to trap the error . below i provide the coding for
both:
a) the first search form
Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "statusall"

stLinkCriteria = "[WWID]=" & "'" & Me![WWID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdSearch_Click:
Exit Sub

Err_cmdSearch_Click:
MsgBox Err.Description
Resume Exit_cmdSearch_Click

End Sub

b) on open event in the second form
Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no records to display at this time." _
, vbInformation, "No Records"
Cancel = True
End If
End Sub

Can you please provide me the coding and tell me d exact location to
place it?

Thanks.
rq******@sympatico.ca wrote:
On Jan 17, 1:58 am, "kev" <kevi....@gmail.comwrote:
Hi Folks,

I have created a search query in which it successfully returns correct
results. When there are no records returned, instead of giving out a
blank form i created a pop-up msg which is attached to the On Open
event.
However, right after the msg box pops saying"no records", this is
followed by another msg box with "TheOpen Form action was cancelled".

Is there a way i can eliminate the second msg box from appearing?

Or is there another approach in which i want a form to display the
message someting like below:

Your search on (search criteria) returned no results.

what i need is something like when there is matching records, open form
"a" and if there is no records open form"b" stating Your search on
(search criteria) returned no results.

Pls help.

Thanks.

In the code module that calls the open form a, you need to trape for
error 2501 and resume next. (Error 2501 is "The Open Form event was
cancelled")
Jan 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Victor | last post by:
In my php page I'm using a mysql database. I want to run a query on a table, then run a second query on the results returned from the first query. In mysql this would be the same as running a...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
0
by: Robert Wille | last post by:
I have a number of very common queries that the optimizer plans a very inefficient plan for. I am using postgres 7.2.3. I vacuum hourly. I'm wonderingwhat I can do to make the queries faster. Here...
1
by: Robert Wille | last post by:
I have a number of very common queries that the optimizer plans a very inefficient plan for. I am using postgres 7.2.3. I vacuum hourly. I'm wonderingwhat I can do to make the queries faster. Here...
11
by: Randy Weber | last post by:
I am getting unexpected results with a Like Query using ASP and an Access database. This query - SELECT PN, Qty From Inventory Where PN Like 'SSW-10%'; returns what I expect: PN ...
4
by: Martin Lacoste | last post by:
Can I get field names to be returned as data in a query's results? E.g. I have 3 fields (City, Town, Village), and want the results to incorporate these as data, e.g.: City 2 Town 4...
4
by: Mark | last post by:
Hi all, I have a query which returns 56 results every time. 1 field of the query contains the results of an expression where 55 will contain decimal points and 1 will be a whole number. Is there a...
2
by: mmitchell_houston | last post by:
I'm working on a .NET project and I need a single query to return a result set from three related tables in Access 2003, and I'm having trouble getting the results I want. The details: ...
1
by: holmm | last post by:
Feel free to critise/comment. I've been slightly thrown in at the deep end! I'm building a query to count the number of test results that are unapproved, Out of spec, null etc per manufacturing...
1
by: csolomon | last post by:
Hello: I am using two queries to get one result set. The issue is, I return no data when I combine them into one query. I have listed both queries, as well as the 3rd query that shows them...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.