473,657 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print from date selection

DD
I have a mainform with a subform.
The main form as a dropdown box "chooseDate ", in the afterupdate event
i requery the subform so all records with the same date are viewed.
Now i only want to print the selected records of the selected month
Can any one advise on the code to add to the print button

i have tried this
StrLinkCriteria = "[fsubGSTRecieved].forms![paiddate] = " &
Me![chooseMonth]
this does not work
any ideas
regards
DD
Nov 12 '05 #1
1 2122
Hi David,

You *might* be able to accomplish what you need by simply "wrapping" your
date in "#" 's... like this:

StrLinkCriteria = "[fsubGSTRecieved].forms![paiddate] = " &
"#" & Me![chooseMonth] & "#"
Here's what *I* do instead in this type of situation, and it seems to work
quite well.
=============== =============== =============== ==========
1.) Using the AfterUpdate event of the combo or list box, build an SQL
statement in code including the WHERE , which is determined by the combo-box
item(s) selected.
2.) Use the resulting SQL statement as the recordsource for the subform.
This in effect "requeries" the subform automatically.
3.) Use that same SQL statement as the recordsource for the report. What you
see in the subform is what you get in the report. (WYSIWYG)

Here's some (commented) sample code that you can modify to suit your needs:

This example uses two different controls to modify the SQL , so I just wrote
one Sub procedure that does the "Requery", and call that from each of the
control's AfterUpdate event.

"lstTransTy pe" is a multi-select list box that is used to include different
transaction types in the results.
"cboSortBy" is a combo-box containing selected field names. Choosing a field
name causes the results to be sorted by that field.
*************** *************** *************** **********
Option Compare Database
Option Explicit

Dim MySQL As String 'This needs to be declared in the form declaration
section so that is in scope for various procedures on this form
=============== =============

Private Sub lstTransType_Af terUpdate()
sRequerySubform
End Sub
=============== =============
Private Sub cboSortBy_After Update()
sRequerySubform
End Sub
=============== =============

Public Sub sRequerySubform ()
'"Add All to List" Courtesy: Dev Ashish
' http://www.mvps.org/access/forms/frm0043.htm

Dim ctl As Control
Dim varItm As Variant

Dim strSelected As String

Set ctl = Me.lstTransType
For Each varItm In ctl.ItemsSelect ed

If Len(strSelected ) > 0 Then
strSelected = strSelected & ", " & chr$(39) &
ctl.ItemData(va rItm) & chr$(39)
Else
strSelected = chr$(39) & ctl.ItemData(va rItm) & chr$(39)
End If

Next varItm

'Debug.Print strSelected

MySQL = "" 'Clear the string variable

'Construct the MAIN SQL statement here
MySQL = MySQL & "SELECT tblTransactions .* FROM tblTransactions "

'Now test for and add the WHERE portion here
If Len(strSelected ) > 0 And InStr(1, strSelected, "All") = 0 Then
MySQL = MySQL & "WHERE (((tblTransacti ons.TransType)I n("
MySQL = MySQL & strSelected
MySQL = MySQL & "))) "
End If

'Again, test for and add the ORDER BY here.
If Not IsNull(Me.cboSo rtBy) Then
MySQL = MySQL & "ORDER BY "
MySQL = MySQL & Me.cboSortBy
End If

'Finally, "close out" the SQL string using the semi-colon
MySQL = MySQL & "; "

'Check the resulting SQL string.
'If an error is displayed, you can copy the SQL string from the debug window
into a new query in order to help determine why it isn't working
'Debug.Print MySQL

'Setting the subform's Recordsource here automatically updates the display.
No need to requery the subform.
Me.sbfsupplierT ransactions.For m.RecordSource = MySQL
Set ctl = Nothing

End Sub
=============== =============
Private Sub cmdTransactions Report_Click()
On Error GoTo Err_cmdTransact ionsReport_Clic k

Dim stDocName As String

stDocName = "rptTransaction s"
'Use the same SQL string generated above as the recordsource for the
report. (WYSIWYG!)
DoCmd.OpenRepor t stDocName, acPreview, MySQL

Exit_cmdTransac tionsReport_Cli ck:
Exit Sub

Err_cmdTransact ionsReport_Clic k:
MsgBox Err.Description
Resume Exit_cmdTransac tionsReport_Cli ck

End Sub
=============== =============
--
HTH,
Don
=============== ==============
Use My*****@Telus.N et for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.
=============== ==============
"DD" <da**********@b igpond.com.au> wrote in message
news:14******** *************** ***@posting.goo gle.com...
I have a mainform with a subform.
The main form as a dropdown box "chooseDate ", in the afterupdate event
i requery the subform so all records with the same date are viewed.
Now i only want to print the selected records of the selected month
Can any one advise on the code to add to the print button

i have tried this
StrLinkCriteria = "[fsubGSTRecieved].forms![paiddate] = " &
Me![chooseMonth]
this does not work
any ideas
regards
DD

Nov 12 '05 #2

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

Similar topics

3
2108
by: DD | last post by:
I have frmMain and fsub you choose a month from the ChooseMonth combo and all the records for that month are nopw visible in the fsub I know print with the following Where and only recieve the record that is selected in the fsub when i want all the records Can some one help correct my code dd strDocName = "rptGSTCollected" strWhere = "= #" & Me!fsubGSTRecieved! & "#" DoCmd.OpenReport strDocName, acPreview, , strWhere
1
238
by: DD | last post by:
I have a mainform with a subform. The main form as a dropdown box "chooseDate", in the afterupdate event i requery the subform so all records with the same date are viewed. Now i only want to print the selected records of the selected month Can any one advise on the code to add to the print button i have tried this StrLinkCriteria = ".forms! = " & Me! this does not work
1
1470
by: Dave Mann | last post by:
Right i have tried but failed! I have a Form and a subform Fields in Sub form are:- Planned - Checkbox Unplanned - Checkbox Maint Type - Dropdown selection Date Done Description
3
3260
by: Matt MacDonald | last post by:
I'm trying to run a report using a form containing a crystal report viewer, but I keep getting an error saying tha "The specified value type is different to the current value type I'm trying to use date parameters. The parameter is set up as a date in the report Here's the code Dim paramfields As New CrystalDecisions.Shared.ParameterField Dim discreteval As New CrystalDecisions.Shared.ParameterDiscreteValu Dim reporter As New...
1
11473
by: kirkus84 | last post by:
I am currently trying to do a multiple record mail merge through a query via a command button on a form. The query basically displays customers who have said yes to privacy. The user inputs a date into txtDate on frmDate and the clicks "View Queried Privacy Records" Once they click this it opens the query form frmPrivacy which then has a command button cmdMailmerge to perform the mail merge and print the records that result from that query. (I...
0
964
ilikepython
by: ilikepython | last post by:
Hello, I'm trying to use visual basic to automatically write headers. Something like this: <my name> <class> <date> <my <class>'s teacher's name> I went to record macro and I did the header manually and I got this code: Sub EnglishHeader() If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
0
3679
by: jans78 | last post by:
Appreciate if you all can help me to solve my Crystal Report problems First, I create some parameters and one of the parameters is Date. I set the parameter for the date is String. For example : parameter 1 - From Collection Date parameter 2 - To Collection Date I should display the results base on this selection criteria : 1) specific date - to enter specific date in FROM and TO field eg 20071227 to 20071227 2) greater or equal date -...
4
2676
by: Mtek | last post by:
Hi, We have a combo box on our page, which gets populated via a MySQL Query in PHP. What we want to do is to print the values on the page in a table that correspond the to selection from the combo box without a page refresh. I assume that I'll need to query ALL the needed values from the database and store them in an array This can be done in PHP. Drawing
1
4109
by: abil | last post by:
i've already build a program that contain all the price, the change given back to the customer but i dun have no idea which function i should use to do program print report... #include <cstdlib> #include <iostream> #include<iomanip> using namespace std; const int TEH_TARIK = 0; const int NESCAFE = 1; const int HORLICK = 2; const int TEH_O = 3;
0
8394
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
8306
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
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
8605
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
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
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
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.