473,387 Members | 1,834 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.

Conditional statement stopped working...

135 100+
Expand|Select|Wrap|Line Numbers
  1.  If IsNull(Me![Text77]) And Me.Check107 = False And
  2.  Me.Check111 = False Then
  3. MsgBox "Enter the number of copies to print and try again. "
  4. Exit Sub
  5. Else
  6. DoCmd.PrintOut acPrintAll, , , , Me.Text77
  7. End If
I was using this code to have my user receive a message informing him to enter a print amount if he left the text (Text77) field blank. I believe I had it working (I can't remember, it could have been a variation of this) and now it just runs right past the first part of the code and goes right to the DoCmd. I then get an internal error because my text field is blank. What do I do to remedy my code? Again, I would like my user to receive a message telling him to enter a print amount and then I want the event to cancel before going to the print function. Thank You.
May 20 '09 #1
7 1612
Denburt
1,356 Expert 1GB
What is Check107 and Check111 and why are they involved in this at all?
If either one of those are checked as true then that is your problem. We really need more info in order to go further.
May 20 '09 #2
MyWaterloo
135 100+
I have print button. There is a box (Text77) to select the number of pages to be printed. I also have two checks: 107 is labeled "PDF" and 111 is labeled "DOC." The user can then decide to print and save his purchase order in any of the three ways. The code for the two checks comes before this code. I have even tried the code without the language for the two checks and it still won't work.
Expand|Select|Wrap|Line Numbers
  1.  If IsNull(Me![Text77]) Then
  2. MsgBox "Enter the number of copies to print and try again. "
  3. Exit Sub
  4. Else
  5. DoCmd.PrintOut acPrintAll, , , , Me.Text77
  6. End If 
I want to be able to cancel the event and exit the sub if neither check box is true and the textbox is empty (Null).
May 20 '09 #3
Denburt
1,356 Expert 1GB
Try this
Expand|Select|Wrap|Line Numbers
  1.  if Me.Check107 = False And
  2.  Me.Check111 = False Then
  3. MsgBox "Please select the type of printout you want. "
  4. Exit Sub
  5. end if
  6.  
  7. If len(Me![Text77])=0 Then
  8. MsgBox "Enter the number of copies to print and try again. "
  9. Exit Sub
  10. Else
  11. DoCmd.PrintOut acPrintAll, , , , Me.Text77
  12. End If 
May 20 '09 #4
MyWaterloo
135 100+
@Denburt
I think I didn't make myself clear. I have three options: save as PDF, save as Word DOC, or print to printer. I want to be able to select any one or combo of these 3 options. They are all fired from the same button. If none of these 3 are selected I would like a message box displayed when the button is pushed that tells the user to select some type of output before pushing the button. The problem with the above code is that if I leave the 2 checks false then it will exit the sub and won't run to my print code. If I put the code in reverse the same happens (won't run to PDF,DOC code if my print box is left empty). Did that make sense?
May 21 '09 #5
MyWaterloo
135 100+
Expand|Select|Wrap|Line Numbers
  1. 'The outputs for Check.107 and Check.111 come before this. 
  2.  
  3. If Len(Me![Text77]) = 0 And Me.Check107 = False 
  4. And Me.Check111 = False Then
  5.    MsgBox "Please select the type of printout you want. "
  6.    Exit Sub
  7.    Else
  8.  
  9. If Len(Me![Text77]) = 0 Then
  10. Exit Sub
  11. End If
  12. DoCmd.PrintOut acPrintAll, , , , Me.Text77
  13. End If
  14. End If
This works! I had to add the extra "If Len(Me![Text77]) = 0 Then Exit Sub" at the end right before the PrintOut. The reason was if one of the checks was true the code would run to the PrintOut and then error because the textbox was empty.
Thanks for all the Help!
(Is this the best way to go about this? It works...so that's the point...Right?)
May 21 '09 #6
Denburt
1,356 Expert 1GB
Looks fine glad you got it and happy to be of help.
May 21 '09 #7
NeoPa
32,556 Expert Mod 16PB
I feel like I'm in a mad-house. Everyone's talking as if that code would work, yet there are half-formed If statements on lines that will never process (as far as I can see). No continuation characters anywhere to be seen, yet statements spread across multiple lines.

Am I missing something obvious here?
May 25 '09 #8

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

Similar topics

8
by: neblackcat | last post by:
Would anyone like to comment on the following idea? I was just going to offer it as a new PEP until it was suggested that I post it here for comment & consideration against PEP 308. I'm far...
10
by: Ilik | last post by:
Hi all I'm trying to create a summery table of rain data that holds a record for every 0.1mm of rain in the following format: Station Name, Time, Value A, 2002-12-03 14:44:41.000, 0.1 A,...
8
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format...
3
by: Chuck Reed | last post by:
I am working on a sales report where I show weekly sales by category for each of the 52 weeks in the year. Each record in my table/report has the 52 weeks of sales in it. I want to highlight to top...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
5
by: paulo | last post by:
Can anyone please tell me how the C language interprets the following code: #include <stdio.h> int main(void) { int a = 1; int b = 10; int x = 3;
16
by: Art | last post by:
Can anyone help. I've tried scaling down a script to the bare minimum and it still is not working correctly. What I think should happen is that when the field app_fname is blank, that $hold_chk...
7
by: Andy_Khosravi | last post by:
I use the formatting trick in A97 to simulate conditional formatting in continuous forms. It has, up to this point, worked fine. Today I was making some design changes to the parent form (the...
8
jschrader
by: jschrader | last post by:
I am trying to write a conditional Statement in ASP based on dates/times in a database entry. I'm basically a ASP/web designer and try my best to get into the fun coding, so not sure as to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
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...

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.