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

Input box cancel code

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 5567
Megalog
378 Expert 256MB
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 Expert 256MB
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
Thanks a lot for the reply, It works perfect now
Aug 18 '09 #4
Megalog
378 Expert 256MB
Glad it works out for you, sorry it took 5 days to get a reply to you..
Welcome to Bytes!
Aug 18 '09 #5
:) :) 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
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...
3
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....
3
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...
2
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...
2
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 =...
3
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,...
4
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...
1
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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,...

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.