473,408 Members | 1,908 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,408 software developers and data experts.

Problem with query values from a form

Hi
I have a form that supplies my query with information on two different
variables. The form uses a lookup to display a list of 5 different
customer types and 5 different types of meetings/activities in two
different combo boxes.

Now, the values of form variables go into a query upon which a report
is generated. By using those two variables my form can produce 25
different reports. But the report turns out empty on any combination
involving all types of meeting and/or all types of customers.
Obviously, these values are not part of my meeting and customer types,
and an attempt to make a Is Not Null data entry did not work.

How do I solve this without adding new reports and new queries?

Thanks in advance
Eskil
Nov 13 '05 #1
1 1660
Presumably your query refers to text boxes on your form, so the Criteria row
of the query contains something like:
[Forms].[Form1].[Textbox1]

There are ways to try to make the query try to return records anway, but
they are inefficient and messy and dependent on the data types. A better
solution might be to put a command button on the form to open the report.
You can then build a string to use as the WhereCondition of the OpenReport
action. In building the string, you just ignore any text boxes that are
null, so then all records are returned.

This example shows how to build up the string from the text boxes where the
user entered a value. If you are filtering a Text type field, it needs extra
quotes (as in the 2nd example).

-----------------------code starts------------------------
Private Sub cmdPreview_Click()
Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.Textbox1) Then
strWhere = strWhere & "([SomeNumberField] = " & _
Me.Textbox1 & ") AND "
End If

If Not IsNull(Me.Textbox2) Then
strWhere = strWhere & "([SomeTextField] = """ & _
Me.Textbox2 & """) AND "
End If

'etc for other text boxes as needed.

lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen > 0 Then
strWhere = Left$(strWhere, lngLen)
End If

'Now open the report.
DoCmd.Openreport "MyReport", acViewPreview, , strWhere
End Sub
-----------------------code ends------------------------

If you are filtering dates, see:
http://members.iinet.net.au/~allenbrowne/casu-08.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Eskil" <es********@hotmail.com> wrote in message
news:3d**************************@posting.google.c om...
Hi
I have a form that supplies my query with information on two different
variables. The form uses a lookup to display a list of 5 different
customer types and 5 different types of meetings/activities in two
different combo boxes.

Now, the values of form variables go into a query upon which a report
is generated. By using those two variables my form can produce 25
different reports. But the report turns out empty on any combination
involving all types of meeting and/or all types of customers.
Obviously, these values are not part of my meeting and customer types,
and an attempt to make a Is Not Null data entry did not work.

How do I solve this without adding new reports and new queries?

Thanks in advance
Eskil

Nov 13 '05 #2

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

Similar topics

9
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
3
by: wk6pack | last post by:
Hi, I have an asp page that I would like to do paging. The problem I'm running into is that the same page that prints to the output is also recieving data from the previous page for query...
2
by: Betrock | last post by:
This is probably very simple, but I just can't see my way thru it..... Short version: keyed values(numeric)in a lookup table are stored in a main table. They are displayed as text values - the...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
2
by: mob1012 via DBMonster.com | last post by:
Hi All, I wrote last week about a trigger problem I was having. I want a trigger to produce a unique id to be used as a primary key for my table. I used the advice I received, but the trigger is...
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...
6
by: jej1216 | last post by:
I am trying to put together a PHP search page in which the user can select none, one, two, or three fields to search, and then the results php will build the SQL with dynamic where caluses to reflect...
1
by: Randy Volkart | last post by:
I'm trying to fix a glitch in a complex access database, and have a fairly complex problem... unless there's some obscure easy fix I don't know being fairly new with Access. Basically, the area...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.