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

How do I debug.print a yes/no check box....

Michael Adams
What is the code for debugging a yes/no check box located in a table?

I have tried the common
Expand|Select|Wrap|Line Numbers
  1. debug.print [checkbox];
and what I get is a "Run-time error '2465' Microsoft Office Access can't find the field'|' referred to in your expression." No matter what checkbox field name I use it returns the same error. However, when I use the same code for a text field
Expand|Select|Wrap|Line Numbers
  1. debug.print [textbox];
a value for the field is returned.

What am I doing wrong or right, what do I need to do for this thought to work?
Aug 4 '10 #1

✓ answered by ADezii

Assuming [email] is a Yes/No Field in the WorkOrderTracking Table, then I see no reason why the following Statement will not work:
Expand|Select|Wrap|Line Numbers
  1. EAEcount = Dcount("[Type]", "WorkOrderTracking", "[Type] = 'Incident' and [email] = True") 

12 2487
missinglinq
3,532 Expert 2GB
Assuming that checkbox is actually the name of a checkbox control on your form it should work.

But your statement
What is the code for debugging a yes/no check box located in a table?
makes me wonder if this is actually the case.

Linq ;0)>
Aug 4 '10 #2
ADezii
8,834 Expert 8TB
This is the Syntax I usually use in these circumstances:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print IIf(Me![chkOne], "Yes", "No")
P.S. - You may be getting the Error because the Check Box is not 'Bound'
Aug 4 '10 #3
By using your code, the error is now telling me that it can not find the field that I am looking for. It is acting like the field doesn't exist in the table I am looking at. I also did a link table update before and after the code.

This is what the code looks like:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print [Type]; IIf(Me![email], "yes", "no");
Aug 4 '10 #4
ADezii
8,834 Expert 8TB
Where exactly are you executing this code from, since the Syntax is correct in the proper context. The proper context that I am referring to is from within an Open Form and referring to a Field on it. You simply cannot refer to a Field in a Table otherwise in this manner.
Aug 4 '10 #5
I am executing this code within my case statement on a form for a click event
Aug 4 '10 #6
ADezii
8,834 Expert 8TB
  1. Click() Event for what Control?
  2. Kindly post the entire code segment.
Aug 4 '10 #7
Here is where the private sub is called:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Sub_Cmd_Click()
  2.  
  3. Call EmpAllWorkOrder
  4.     If Me.chkEmp.Value = -1 Then EmpAll
  5.         If Me.chkemail.Value = -1 Then EmpAllEmail
  6.             If Me.chkBnk.Value = -1 Then EmpAllBanks
  7.                 If Me.chkDte.Value = -1 Then EmpAllDateRange
  8.                     If Me.chkVnd.Value = -1 Then EmpAllVendor
  9.  
  10.  
  11. End Sub
This is the private sub:
Expand|Select|Wrap|Line Numbers
  1. Private Sub EmpAllEmail()
  2.  
  3. Dim EAEcount As Integer
  4.  
  5. Select Case Me.chkemail.Value
  6.     Case "-1"
  7.         EAEcount = DCount("[type]", "WorkOrderTracking", "[type]")
  8.         Debug.Print [Type]; IIf(Me![email], "yes", "no");
  9.         Me.TotalTxt.Value = EAEcount
  10.         Me.Repaint
  11.         EAEcount = DCount("[type]", "WorkOrderTracking", "[Type] = 'Incident'")
  12.         Me.Inc_Text.Value = EAEcount
  13.         Me.Repaint
  14.         EAEcount = DCount("[type]", "WorkOrderTracking", "[Type] = 'Request'")
  15.         Debug.Print [Type];
  16.         Me.Req_Text.Value = EAEcount
  17.         Me.Repaint
  18.         EAEcount = DCount("[type]", "WorkOrderTracking", "[Type] = 'Change Order'")
  19.         Debug.Print [Type];
  20.         Me.CO_Text.Value = EAEcount
  21.         Me.Repaint
  22.     Case Else
  23.         Select Case Me.chkemail.Value
  24.             Case "Incident"
  25.                 EAEcount = DCount("[Type]", "workordertracking", "[type] = 'Incident'")
  26.                 Me.Inc_Text.Visible = True
  27.                 Me.Req_Text.Visible = False
  28.                 Me.CO_Text.Visible = False
  29.                 Me.chkWrA.Visible = False
  30.                 Me.Inc_Text.Value = EAEcount
  31.                 Me.TotalTxt.Visible = False
  32.             Case "Request"
  33.                 EAEcount = DCount("[Type]", "workordertracking", "[type] = 'Request'")
  34.                 Me.Inc_Text.Visible = False
  35.                 Me.Req_Text.Visible = True
  36.                 Me.CO_Text.Visible = False
  37.                 Me.chkWrA.Visible = False
  38.                 Me.Req_Text.Value = EAEcount
  39.                 Me.TotalTxt.Visible = False
  40.             Case Else
  41.                 EAEcount = DCount("[Type]", "workordertracking", "[type] = 'Change Order'")
  42.                 Me.Inc_Text.Visible = False
  43.                 Me.Req_Text.Visible = False
  44.                 Me.CO_Text.Visible = True
  45.                 Me.chkWrA.Visible = False
  46.                 Me.CO_Text.Value = EAEcount
  47.                 Me.TotalTxt.Visible = False
  48.         End Select
  49. End Select
  50. End Sub
I am trying to find the value of the field on the workordertracking table so that I can put it in the criteria portion of the count.
Aug 4 '10 #8
ADezii
8,834 Expert 8TB
In general, your code needs to be rewritten, but first of all, if chkEMail is a Check Box which will return a True/False, Yes/No, On/Off Value, the Select Case Statement then makes no sense, namely:
Expand|Select|Wrap|Line Numbers
  1. Select Case Me.chkemail.Value 
  2.   Case "Incident" 
  3.   Case "Request"
  4. End Select
Aug 4 '10 #9
That is because there is a lot more going on than what you are seeing here. You are seeing only a piece of fruit to the entire cherry pie.
My main problem is that I am trying to return a value in my debug.print so that I can put the proper code within the 'criteria' portion of the dcount.
What will happen in the end is that I will have a statement that will look like this:
Expand|Select|Wrap|Line Numbers
  1. EAEcount = Dcount("[Type]", "WorkOrderTracking", "[Type] = 'Incident' and [email] = '-1'")
However, and this is where the problem lies---I do not know what value to put for the [email] field because Access is not recognizing the field[email]. If it did then I would not be having this trouble. I am trying to figure out the field name and the value of that field.
Aug 4 '10 #10
missinglinq
3,532 Expert 2GB
Actually, as ADezii has suggested, you have a lot more going on besides Access not recognizing [email]! As he also said, everything here really needs to be scrapped and redone.

First off, there's no reason to have a Select Case Me.chkemail.Value within a Select Case Me.chkemail.Value! This makes absolutely no sense.

Secondly, if chkemail is, in fact, a checkbox, neither "-1", "Incident" nor "Request" are valid as Values. For a checkbox in VBA the valid choices would be 0/-1 or True/False. You'll notice that none of these valid Values have quotes around them.

As to Access not recognizing [email], is it a checkbox control on your form, or is the control actually named chkemail?

Linq ;0)>
Aug 4 '10 #11
ADezii
8,834 Expert 8TB
Assuming [email] is a Yes/No Field in the WorkOrderTracking Table, then I see no reason why the following Statement will not work:
Expand|Select|Wrap|Line Numbers
  1. EAEcount = Dcount("[Type]", "WorkOrderTracking", "[Type] = 'Incident' and [email] = True") 
Aug 4 '10 #12
Thanks, that is exactly what I needed. "True" was the value I was looking for.

Thanks again.
Aug 4 '10 #13

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

Similar topics

1
by: Steve Leferve | last post by:
Hey folks -- For some reason, debug.print is not placing any text in my locals window. I'm creating some SQL statements, and I usually like to throw them in the window so I can see what they...
3
by: Tim Marshall | last post by:
For an mdb or mde release, does having debug.print without the comment single quote add any processing time to the application? I assume an mde won't since debug.prints would not be compiled in...
3
by: Gunawan | last post by:
In vs 6 I can use debug.print as alternatif debugging value at runtime. Which function that I can use in C# 2005 Express for windows form apps? TIA, Gunawan
6
by: Christian Blackburn | last post by:
Hi Gang, I'm wondering what the VB6 equivalent of Debug.Print is? Thanks in Advance, Christian Blackburn
5
by: MLH | last post by:
I use a fair number of debug.print statements. My apps are fairly well 'peppered' with them. I've often wondered if leaving them in the mdb, creating and rolling out an mde intended for use in the...
9
by: David A. Beck | last post by:
When I do a debug.print("blabla") in VB (VS2005) it doesn't show up in the output window, what gives?
6
by: swartzbill2000 | last post by:
Hello, I have a VB 2005 Express project with a TraceListener-derived class to route Debug.Print output to a log file. It works fine for Debug builds. What is the correct combination of changes to...
3
by: Daniel Manes | last post by:
Strangest thing, but, if I put debug.print statements in my code, they simply get ignored when I run the project. Also, if I try to put a breakpoint on a line containing debug.print, it jumps down...
4
by: Dom | last post by:
VB had a neat object called "Debug". You could use "Debug.Print()" in your code, and you could get useful debugging information in the immediate window. Is there something like this in CSharp? ...
4
by: =?Utf-8?B?R3V5IENvaGVu?= | last post by:
Hi all I tried the (good old...)vb6 command debug.print and it does not work in vb.net 2005 I googled some and found these samples: Debug.WriteLine("hello") Console.WriteLine("hello")...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.