473,379 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Error Message for Query/Form.

Hi :-)

I've designed a query that gathers its information for two tables:-

1)Author and
2) Category

My selection criteria for this query is Author.AuthorName [Enter Author Name] and
Category.CategoryName [Enter Category].

This query works well. However, if I do the following:

"Joe Public" as the Author and
"Faith" as the Category

If this author has books on faith then they will be shown HOWEVER

If he has none, I get a blank form or blank Datasheet view.

For the Form I desire to have some message stating there are no records
when such a situation arises (Any Help rendered would be greatly appreciated)

(Previously someone on this forum highlighted a method with search box criteria from one table and that worked fantastic. NOW I dont know how to apply this for two tables)

Thanks a Mil!
Aug 21 '09 #1
4 1655
ChipR
1,287 Expert 1GB
This will be easy, since it requires very little change from the previous code. You'll have two text or combo boxes for the user to enter criteria, something like txtAuthor and txtCategory. I like combo boxes usually because they autocomplete, but you probably don't want one with many, many entries. Plus with the text box, you might eventually let a user enter partial search criteria and use LIKE to match them. This shouldn't work correctly if either text box is empty or null, so you probably want to check for that.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearchButton_Click() 
  2. Dim intMatches As Integer 
  3. Dim strWhereCondition As String 
  4.     strWhereCondition = "[AuthorName] = """ & txtAuthor _
  5.         & """ AND [CategoryName] = """ & txtCategory & """"
  6.     intMatches = DCount("AuthorName", "myQuery", strWhereCondition) 
  7.     If intMatches > 0 Then 
  8.         DoCmd.OpenForm "frmViewRecords", , , strWhereCondition 
  9.     Else 
  10.         MsgBox "No records found." 
  11.     End If 
  12. End Sub 
Aug 24 '09 #2
Thanks ever so much ChipR, I'm going to look into it.
What I did in the interim was to present a message box on the form's load that would advise the user that a blank form would mean--- no records.
This I thought was unprofessional and not nice design but I did need something to advise the user and not have him/her be at a lost.

Again I thank you ever so much for your responses.
Appreciative!
C.R.
Aug 25 '09 #3
Hi ChipR.
I tried it, however, it does not seem to be functional on my end.
If my datatype for CategoryName and AuthorName is "text" does that make a difference? (just a wild guess)
Thanks again!
C.R.
Aug 26 '09 #4
Ok ChipR. Thanks a mil, I now got it to work.
Appears that I had line of code in an incorrect order......well all I did was adjust the order and it works thanks again :-)
Aug 26 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
7
by: Jack | last post by:
Hi, I am trying to test a sql statement in Access which gives me the error as stated in the heading. The sql statement is built as a part of asp login verification, where the userid and password...
4
by: Bryan Tang | last post by:
I built an ASP to search the content in index server. It is ok if search in English. Whenever I search in Chinese, I will got the following error message, CreateRecordset ?u?~ '80004005' ...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
4
by: MLH | last post by:
< < < VERY LOW PRIORITY POST > > > When I'm creating a query in the QBE grid whose SQL looks like this... INSERT INTO tblOwners (OwnerFName, OwnerLName, OwnerAddr, OwnerCity, OwnerState,...
18
by: William | last post by:
I have the following javascript function that updates a scroll_list and sends the updated entry (with its index) to a server script ( i.e. http://mkmxg00/cgi/confirmUpload.pl ) for further...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
8
by: nishkrish | last post by:
Hi, I am new to access I created the form and report from Allen Browne's Frmwhat Date the way he has described but when i preview report it shows StartDate: name? Enddate: name? am i suppose...
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.