In the input box if we click ok or cancel the invoice prints. By default the credit card info is 0, and most of the cases its 0 even when we want to take a print out i.e., the value is changed.
I tried doing If Payment = "" Then Exit sub,
but it exits the sub if I press ok or cancel since the credit card value is not changed and remains to be 0.
What changes can I make so that if OK is clicked the document prints and if cancel is clicks it exits the sub, even if credit card value continues to remain 0. Its very very urgent! - Private Sub PRINT_Click()
-
On Error Resume Next
-
' CopyNumber is global
-
Dim NumCopies As Integer, ReportDest As Integer, Msg As String, Payment As Currency, Response As String
-
-
'Hide the Invoice Print Dialog
-
Forms![yInvoice Print Dialog].Visible = False
-
' Destination is Print Preview
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Type of Output] = 1 Then
-
ReportDest = A_PREVIEW
-
Else ' Destination is printer
-
ReportDest = A_NORMAL
-
End If
-
NumCopies = Forms![yInvoice Print Dialog]![TabSubfrm].Form![Number Copies].Value
-
PrintMessages = Forms![yInvoice Print Dialog]![TabSubfrm].Form![Print Messages].Value
-
PrintPayments = Forms![yInvoice Print Dialog]![TabSubfrm].Form![Print Payments].Value
-
' Determine Print Criteria selected
-
-
Msg = "How much is being paid by" & vbCrLf & "Credit Card on this Invoice?"
-
Payment = InputBox(Msg, "Credit Card Payment", 0)
-
-
Select Case Forms![yInvoice Print Dialog]![TabSubfrm].Form![Type of Print]
-
Case 1 ' Current Record
-
' Print Standard Invoice
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Invoice] = -1 Then
-
For CopyNumber = 1 To (NumCopies - 1)
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
-
DoCmd.OpenReport "Invoice -Separated", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]"
-
Else
-
DoCmd.OpenReport "Invoice", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
-
End If
-
Next CopyNumber
-
DoCmd.OpenReport "Invoice-Unsigned", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
-
-
End If
-
' Print Pro Forma Invoice
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Pro Forma Invoice] = -1 Then
-
For CopyNumber = 1 To NumCopies
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
-
DoCmd.OpenReport "Invoice -Separated", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]"
-
Else
-
DoCmd.OpenReport "Invoice-ProForma Title", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
-
End If
-
Next CopyNumber
-
End If
-
' Print Packing List
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Packing List] = -1 Then
-
For CopyNumber = 1 To NumCopies
-
DoCmd.OpenReport "Packing List", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]"
-
Next CopyNumber
-
End If
-
' Print Commercial Invoice one copy only
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Commercial Invoice] = -1 Then
-
DoCmd.OpenReport "Invoice-Customs", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
-
End If
-
Case 2 ' Date Range
-
' Print Standard Invoice
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Invoice] = -1 Then
-
For CopyNumber = 1 To NumCopies
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
-
DoCmd.OpenReport "Invoice -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])"
-
Else
-
DoCmd.OpenReport "Invoice", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])"
-
End If
-
Next CopyNumber
-
End If
-
' Print Simple Invoice
-
'If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Simple Invoice] = -1 Then
-
' For CopyNumber = 1 To NumCopies
-
' If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
-
' DoCmd.OpenReport "Invoice Single Line -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])"
-
' Else
-
' DoCmd.OpenReport "Invoice Single Line", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])"
-
' End If
-
' Next CopyNumber
-
'End If
-
' Print Preprinted Form
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Preprinted Form] = -1 Then
-
For CopyNumber = 1 To NumCopies
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
-
DoCmd.OpenReport "Invoice Just Data -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])"
-
Else
-
DoCmd.OpenReport "Invoice Just Data", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])"
-
End If
-
Next CopyNumber
-
End If
-
Case 3 ' Customer Number
-
' Print Standard Invoice
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Invoice] = -1 Then
-
For CopyNumber = 1 To NumCopies
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
-
DoCmd.OpenReport "Invoice -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])"
-
Else
-
DoCmd.OpenReport "Invoice", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])"
-
End If
-
Next CopyNumber
-
End If
-
' Print Pro Forma Invoice
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Pro Forma Invoice] = -1 Then
-
For CopyNumber = 1 To NumCopies
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
-
DoCmd.OpenReport "Invoice -Separated", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]"
-
Else
-
DoCmd.OpenReport "Invoice-ProForma Title", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
-
End If
-
Next CopyNumber
-
End If
-
' Print Preprinted Form
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Preprinted Form] = -1 Then
-
For CopyNumber = 1 To NumCopies
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
-
DoCmd.OpenReport "Invoice Just Data -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])"
-
Else
-
DoCmd.OpenReport "Invoice Just Data", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])"
-
End If
-
Next CopyNumber
-
End If
-
' Print Mailing Labels
-
If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Commercial Invoice] = -1 Then
-
DoCmd.OpenReport "Invoice-Customs", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])"
-
End If
-
End Select
-
' DoCmd.Close A_FORM, "yInvoice Print Dialog"
-
-
End Sub
5 5591 Megalog 378
Recognized Expert Contributor
Here's a quick fix, since you said it was urgent.
Add this to line 4:
Replace line 20 with: - vInput = InputBox(Msg, "Credit Card Payment", 0)
-
-
If vInput = "" Then
-
Exit Sub
-
Else
-
Payment = CCur(vInput)
-
End If
Megalog 378
Recognized Expert Contributor
or you can replace line 20 with this: - If IsNumeric(vInput) Then
-
Payment = CCur(vInput)
-
ElseIf vInput <> "" Then
-
MsgBox "Please enter numeric data only.", vbInformation, "Input Type Mismatch"
-
Exit Sub
-
Else
-
Exit Sub
-
End If
Unlike the first example I gave, this will test the input type in two ways.. so if someone types in "Yo wassup" in the text box it wont give you an error when it tries to convert to currency.
Thanks a lot for the reply, It works perfect now
Megalog 378
Recognized Expert Contributor
Glad it works out for you, sorry it took 5 days to get a reply to you..
Welcome to Bytes!
:) :) I am going to come up with lots of more doubts in the near future, will keep you posted, thanks a tonne!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Csaba2000 |
last post by:
I want to be able to programatically click on the center of an <INPUT type=image ...> element (I only care about IE
5.5+). This should work regardless of whether IE has focus. Normally you would do myDomElement.click and the mouse
doesn't matter, but in the case of an input image element, what happens is the submitted url has something like
"?x=12&y=7" appended to it (the numbers vary per mouse position on the clicked element). If you hit...
|
by: Pete Wilson |
last post by:
How can I highlight the <input type="submit"> object that I want to
highlight?
1. In my form, the user enters his ID. He sees two submit "buttons,"
left labeled Cancel, the right labeled Signup.
2. If he enters his ID and selects the Signup button with his mouse,
all is well.
3. But if he enters his ID and then hits the Enter key, then the
|
by: Dalan |
last post by:
I have been using a module for printing labels in Access 97, and
although it works fine, I would like to resolve a minor problem. The
module allows for setting the number of labels to print and/or to
skip; however, the Cancel command button does not function at all, nor
does clicking the X-close. Clicking either one is the same as clicking
the OK button. I have tried virtually everything, but to no avail.
Since the module creates and...
|
by: R Bolling |
last post by:
I am using a routine to check to see if a phone number (PK) has alread
been entered, and takes the user to that record if it is found -- as
follows:
Private Sub Contact_telephone___BeforeUpdate(Cancel As Integer)
Dim rs As DAO.Recordset
Dim iAns As Integer
Set rs = Me.RecordsetClone
rs.FindFirst " = '" & Me! & "'"
If Not rs.NoMatch Then
|
by: Mark Lees |
last post by:
I want to create an input mask for a phone number and I would like the
area code to always be (801). However, I want the users to be able to
edit it if necessary.
Would it look like this = !"(801) 000\-0000;;_" ?
| |
by: BerkshireGuy |
last post by:
Is there a way to setup an input mask to be a range of numbers? For
instance, only allowing 1,2,3,4 or just 1 or 2. Or should I just do a
test in the BeforeUpdate event of the control?
Thanks,
Brian
|
by: polarz |
last post by:
I've written a program that pulls data from the internet and puts it
into a datagrid. When the number of rows reaches a certain point my
program freezes.
Is there a limit to the number of rows you can add? If so, is there a
way to get around this?
Any suggestions are much appreciated. Thanks.
|
by: Louis Cypher |
last post by:
I'm working on an application (OEM) using c# that uses input from a keyboard
and a USB Barcode Scanner.
I need to be able to identify keystrokes from the barcode scanner and remove
them from the message queue, regardless of what application has focus.
I can identify the keystrokes and input device by registering for raw input
(RegisterRawInputDevices) and processing the WM_INPUT message. This gives
me the keystrokes and the ability to...
|
by: Jimmy |
last post by:
Quick question for you. I'm using a small form for users to input a range of
dates for a report (similar to the date range forms used in MS templates)
that has an ok and a cancel button. How can I set up the cancel button so
that is does just that? As it is right now, the event for the cancel button
is simply docmd.close but if I click this button, ms prompts me to enter
parameter values for begindate and enddate. If i cancel out of these...
|
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,...
|
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...
| |
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...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |