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

Home Posts Topics Members FAQ

Input box cancel code

3 New Member
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!



Expand|Select|Wrap|Line Numbers
  1. Private Sub PRINT_Click()
  2.     On Error Resume Next
  3.     ' CopyNumber is global
  4.     Dim NumCopies As Integer, ReportDest As Integer, Msg As String, Payment As Currency, Response As String
  5.  
  6.     'Hide the Invoice Print Dialog
  7.     Forms![yInvoice Print Dialog].Visible = False
  8.     ' Destination is Print Preview
  9.     If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Type of Output] = 1 Then
  10.         ReportDest = A_PREVIEW
  11.       Else      ' Destination is printer
  12.         ReportDest = A_NORMAL
  13.     End If
  14.     NumCopies = Forms![yInvoice Print Dialog]![TabSubfrm].Form![Number Copies].Value
  15.     PrintMessages = Forms![yInvoice Print Dialog]![TabSubfrm].Form![Print Messages].Value
  16.     PrintPayments = Forms![yInvoice Print Dialog]![TabSubfrm].Form![Print Payments].Value
  17.     ' Determine Print Criteria selected
  18.  
  19.     Msg = "How much is being paid by" & vbCrLf & "Credit Card on this Invoice?"
  20.     Payment = InputBox(Msg, "Credit Card Payment", 0)
  21.  
  22.     Select Case Forms![yInvoice Print Dialog]![TabSubfrm].Form![Type of Print]
  23.         Case 1    ' Current Record
  24.             ' Print Standard Invoice
  25.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Invoice] = -1 Then
  26.                 For CopyNumber = 1 To (NumCopies - 1)
  27.                     If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
  28.                         DoCmd.OpenReport "Invoice -Separated", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]"
  29.                     Else
  30.                         DoCmd.OpenReport "Invoice", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
  31.                     End If
  32.                 Next CopyNumber
  33.                         DoCmd.OpenReport "Invoice-Unsigned", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
  34.  
  35.             End If
  36.             ' Print Pro Forma Invoice
  37.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Pro Forma Invoice] = -1 Then
  38.                 For CopyNumber = 1 To NumCopies
  39.                     If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
  40.                         DoCmd.OpenReport "Invoice -Separated", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]"
  41.                     Else
  42.                         DoCmd.OpenReport "Invoice-ProForma Title", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
  43.                     End If
  44.                 Next CopyNumber
  45.             End If
  46.             ' Print Packing List
  47.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Packing List] = -1 Then
  48.                 For CopyNumber = 1 To NumCopies
  49.                         DoCmd.OpenReport "Packing List", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]"
  50.                 Next CopyNumber
  51.             End If
  52.             ' Print Commercial Invoice one copy only
  53.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Commercial Invoice] = -1 Then
  54.             DoCmd.OpenReport "Invoice-Customs", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
  55.             End If
  56.         Case 2      ' Date Range
  57.             ' Print Standard Invoice
  58.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Invoice] = -1 Then
  59.                 For CopyNumber = 1 To NumCopies
  60.                     If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
  61.                         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])"
  62.                     Else
  63.                         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])"
  64.                     End If
  65.                 Next CopyNumber
  66.             End If
  67.             ' Print Simple Invoice
  68.             'If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Simple Invoice] = -1 Then
  69.             '    For CopyNumber = 1 To NumCopies
  70.             '        If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
  71.             '            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])"
  72.             '        Else
  73.             '            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])"
  74.             '        End If
  75.             '    Next CopyNumber
  76.             'End If
  77.             ' Print Preprinted Form
  78.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Preprinted Form] = -1 Then
  79.                 For CopyNumber = 1 To NumCopies
  80.                     If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
  81.                         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])"
  82.                     Else
  83.                         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])"
  84.                     End If
  85.                 Next CopyNumber
  86.             End If
  87.         Case 3      ' Customer Number
  88.             ' Print Standard Invoice
  89.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Invoice] = -1 Then
  90.                 For CopyNumber = 1 To NumCopies
  91.                     If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
  92.                         DoCmd.OpenReport "Invoice -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])"
  93.                     Else
  94.                         DoCmd.OpenReport "Invoice", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])"
  95.                     End If
  96.                 Next CopyNumber
  97.             End If
  98.             ' Print Pro Forma Invoice
  99.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Pro Forma Invoice] = -1 Then
  100.                 For CopyNumber = 1 To NumCopies
  101.                     If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
  102.                         DoCmd.OpenReport "Invoice -Separated", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]"
  103.                     Else
  104.                         DoCmd.OpenReport "Invoice-ProForma Title", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment
  105.                     End If
  106.                 Next CopyNumber
  107.             End If
  108.             ' Print Preprinted Form
  109.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Preprinted Form] = -1 Then
  110.                 For CopyNumber = 1 To NumCopies
  111.                     If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then
  112.                         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])"
  113.                     Else
  114.                         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])"
  115.                     End If
  116.                 Next CopyNumber
  117.             End If
  118.             ' Print Mailing Labels
  119.             If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Commercial Invoice] = -1 Then
  120.                         DoCmd.OpenReport "Invoice-Customs", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])"
  121.             End If
  122.     End Select
  123. '    DoCmd.Close A_FORM, "yInvoice Print Dialog"
  124.  
  125. End Sub
Aug 13 '09 #1
5 5591
Megalog
378 Recognized Expert Contributor
Here's a quick fix, since you said it was urgent.

Add this to line 4:

Expand|Select|Wrap|Line Numbers
  1. Dim vInput As Variant
Replace line 20 with:

Expand|Select|Wrap|Line Numbers
  1. vInput = InputBox(Msg, "Credit Card Payment", 0)
  2.  
  3. If vInput = "" Then
  4.     Exit Sub
  5. Else
  6.     Payment = CCur(vInput)
  7. End If
Aug 18 '09 #2
Megalog
378 Recognized Expert Contributor
or you can replace line 20 with this:

Expand|Select|Wrap|Line Numbers
  1. If IsNumeric(vInput) Then
  2.     Payment = CCur(vInput)
  3. ElseIf vInput <> "" Then
  4.     MsgBox "Please enter numeric data only.", vbInformation, "Input Type Mismatch"
  5.     Exit Sub
  6. Else
  7.     Exit Sub
  8. 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.
Aug 18 '09 #3
snehadulur
3 New Member
Thanks a lot for the reply, It works perfect now
Aug 18 '09 #4
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!
Aug 18 '09 #5
snehadulur
3 New Member
:) :) I am going to come up with lots of more doubts in the near future, will keep you posted, thanks a tonne!
Aug 18 '09 #6

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

Similar topics

4
17247
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...
3
7716
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
3
2475
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...
2
2829
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
2
3052
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;;_" ?
3
2071
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
4
1887
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.
1
6814
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...
4
2815
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...
0
8302
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
8820
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
8718
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...
0
8601
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
7314
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, 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...
1
6162
isladogs
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...
0
4150
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
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1601
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.