473,781 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print combobox search

Jan
I am having problems trying to print a report based on a form. This
is a search form only, no data input. There is a query that the form
looks at, but then there are numerous comboxes that you can pick
information from either one or many and press a search button. See
code below for the "Case Select" that was used to make up the
comboboxes. Not a filtered list. My problem is that when I try to
print, it prints all records before the search. I need it to print
what I had just searched. This could be one or many records. I am
learning VB and it can follow it pretty good.

Private Sub cmdSearch_Click ()
Dim i As Integer
Dim stWhere As String
Dim stDelim As String

For i = 0 To 12
Select Case i
Case 0: stDelim = "'" 'text data type
Case 1: stDelim = "'" 'text data type
Case 2: stDelim = "'" ' Text data type
Case 3: stDelim = vbNullString ' numeric data type
Case 4: stDelim = vbNullString ' numberic data type
Case 5: stDelim = "'" 'text data type
Case 6: stDelim = "'" ' text data type
Case 7: stDelim = vbNullString 'numeric data type
Case 8: stDelim = vbNullString 'numeric data type
Case 9: stDelim = "@" ' currency data type
Case 10: stDelim = "'" 'text data type
Case 11: stDelim = "'" 'text data type
Case 12: stDelim = "'" 'Text data type

End Select
If Nz(Me("Criteria " & i), vbNullString) <> vbNullString Then
If Me("Criteria" & i) <> "<All>" Then
stWhere = stWhere & " AND " & Me("Criteria" & i).Tag &
" = " & stDelim & Me("Criteria" & i) & stDelim
End If
End If
Next i
If stWhere <> vbNullString Then
stWhere = Mid$(stWhere, 6)
Me.Filter = stWhere
Me.FilterOn = True
Else
MsgBox "Please enter some criteria.", vbExclamation, "No
Criteria Entered"
End If
End Sub

Any help would be great!
Thanks, Jan
Nov 12 '05 #1
4 2412
Jan,

The problem is that all your search results go out of scope when the procedure,
Private Sub cmdSearch_Click (), is done; meaning they are no longer available to
the query your report is based on. Put the following code in the Click event of
a button to do what you want:
(This is pseudocode which you can use to create the actual code!)

DoCmd.OpenForm "YourSearchForm ",,,,,acDia log
DoCmd.OpenRepor t "YourReport ", acPreview

On your search form you need a button with the following code in the Click
event:
Me.Visible = False

On your search form, you have to remove all the ways the form can be closed. The
user has to click on the above button to get out of the search form.

Put the following code in the Close event of your report:
DoCmd.Close acForm, "YourSearchForm "

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com
"Jan" <Ja*********@we atherford.com> wrote in message
news:8d******** *************** ***@posting.goo gle.com...
I am having problems trying to print a report based on a form. This
is a search form only, no data input. There is a query that the form
looks at, but then there are numerous comboxes that you can pick
information from either one or many and press a search button. See
code below for the "Case Select" that was used to make up the
comboboxes. Not a filtered list. My problem is that when I try to
print, it prints all records before the search. I need it to print
what I had just searched. This could be one or many records. I am
learning VB and it can follow it pretty good.

Private Sub cmdSearch_Click ()
Dim i As Integer
Dim stWhere As String
Dim stDelim As String

For i = 0 To 12
Select Case i
Case 0: stDelim = "'" 'text data type
Case 1: stDelim = "'" 'text data type
Case 2: stDelim = "'" ' Text data type
Case 3: stDelim = vbNullString ' numeric data type
Case 4: stDelim = vbNullString ' numberic data type
Case 5: stDelim = "'" 'text data type
Case 6: stDelim = "'" ' text data type
Case 7: stDelim = vbNullString 'numeric data type
Case 8: stDelim = vbNullString 'numeric data type
Case 9: stDelim = "@" ' currency data type
Case 10: stDelim = "'" 'text data type
Case 11: stDelim = "'" 'text data type
Case 12: stDelim = "'" 'Text data type

End Select
If Nz(Me("Criteria " & i), vbNullString) <> vbNullString Then
If Me("Criteria" & i) <> "<All>" Then
stWhere = stWhere & " AND " & Me("Criteria" & i).Tag &
" = " & stDelim & Me("Criteria" & i) & stDelim
End If
End If
Next i
If stWhere <> vbNullString Then
stWhere = Mid$(stWhere, 6)
Me.Filter = stWhere
Me.FilterOn = True
Else
MsgBox "Please enter some criteria.", vbExclamation, "No
Criteria Entered"
End If
End Sub

Any help would be great!
Thanks, Jan

Nov 12 '05 #2


Thank you so much! Great information. I am learning so much. You are
the only forum who would help me.

Jan
Houston, TX

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

Wait, I am still only getting what happened before the search. Did I
need to put the DoCmds on the Search button or the print button?

Jan
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4
The Docmds go on the Print button. When you click that button, your search form
opens and you set all your search criteria in the comboboxes. What you are
calling the Search button runs the one line of code, Me.Visible = False.

The acDialog causes the code to pause until your Search form either closes or
becomes not visible. When it does, the code resumes and opens your report. At
the point your report opens, your Search form needs to be open (but not visible)
so your report query can get its criteria. Your Search form needs to stay open
so when you print the report the report can run the report query again. That's
why you don't close the Search form until the report closes.

Steve
PC Datasheet

"Jan Crocker" <ja*********@we atherford.com> wrote in message
news:40******** *************@n ews.frii.net...

Wait, I am still only getting what happened before the search. Did I
need to put the DoCmds on the Search button or the print button?

Jan
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #5

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

Similar topics

6
2320
by: Wim van Rosmalen | last post by:
I've upgraded MS-Access 2002 to a MS-Access Project (adp), so now I have to deal with more sophisticated queries (may I call them so?) like stored procedures. I have a form with a combobox for selections and a textbox to enter a certain value. Let us say I call the combobox @select and the textbox @find. The combobox always shows the first of the items to select. Now I want to return a message if nothing is found, or if nothing has been...
4
392
by: Jan | last post by:
I am having problems trying to print a report based on a form. This is a search form only, no data input. There is a query that the form looks at, but then there are numerous comboxes that you can pick information from either one or many and press a search button. See code below for the "Case Select" that was used to make up the comboboxes. Not a filtered list. My problem is that when I try to print, it prints all records before the...
8
12106
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
7
23530
by: NCrum | last post by:
I want to set the Default value of a Combobox for any changeable record and have got this working but it is totaly unsatisfactory see the code below I loop through the items in the Combo looking for a match between cVal and the selectedValue then stop when I do have a match the obvious problem is that each iteration fires the selectedIndexChanged but also for a large list this will slow everything down. There must be a better way int...
5
5916
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique CompanyID's. The second combobox will contain unique memberID's. Each of the tables that I have to search contain a CompanyID and a memberID field, and these fields are not unique in the respective tables. Like CompanyID, MemberID
4
1818
by: JJGarcia | last post by:
Hi Everyone, I'll try to explain the process I'm following, I'm new to this so I'm triying the easy way first, probably the lasyest too! I created a new Project, drag in to it a SQLConnection, configured, dragged an Dataadapter per each table I need it, then generated the dataset, after that, I stablished the relations between tables, then, went over to the datasources, choose the parent datasource and clicked on the + sign, it...
2
2421
by: Robert_5032 | last post by:
I have a list of companies in a form. I want the users to be able to print in the name of the company they are looking for in a textbox and then ACCESS should update the (continius) form with records of companies that holds the text that the user have printed in. So the textbox should have the "on Change" happening trigged code. I cant find hove this code should look like.... What I have now is: DoCmd.ApplyFilter , "Companyname like '*"...
7
1911
by: samoore33 | last post by:
I am trying to dynamically add items to a listbox or combobox. The items add to either, but when I look through those items, there is nothing there. If I choose an item, it shows up. Not sure why, but the items are not visible in the listbox or combobox until one of the items has been chosen. This of course is not good, since someone can not see the items they need to choose from. Any help would be appreciated.
1
7647
by: Pascal Hagedorn | last post by:
Hello Alltogether, following problem is bugging me :) I am havin a Combobox where i can browse and select my articles. So far so good! Over the time my table "article" growed and now it is not very conveniant to search for articles, the name you dont know exactly Now i would like to realise the same Combobox with a Select statement over the same table "article" as follows:
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10308
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10143
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.