What is the code for debugging a yes/no check box located in a table?
I have tried the common
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
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?
Assuming [email] is a Yes/No Field in the WorkOrderTracking Table, then I see no reason why the following Statement will not work: - EAEcount = Dcount("[Type]", "WorkOrderTracking", "[Type] = 'Incident' and [email] = True")
12 2487
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)>
This is the Syntax I usually use in these circumstances: - Debug.Print IIf(Me![chkOne], "Yes", "No")
P.S. - You may be getting the Error because the Check Box is not ' Bound'
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: - Debug.Print [Type]; IIf(Me![email], "yes", "no");
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.
I am executing this code within my case statement on a form for a click event
- Click() Event for what Control?
- Kindly post the entire code segment.
Here is where the private sub is called: - Private Sub Sub_Cmd_Click()
-
-
Call EmpAllWorkOrder
-
If Me.chkEmp.Value = -1 Then EmpAll
-
If Me.chkemail.Value = -1 Then EmpAllEmail
-
If Me.chkBnk.Value = -1 Then EmpAllBanks
-
If Me.chkDte.Value = -1 Then EmpAllDateRange
-
If Me.chkVnd.Value = -1 Then EmpAllVendor
-
-
-
End Sub
This is the private sub: - Private Sub EmpAllEmail()
-
-
Dim EAEcount As Integer
-
-
Select Case Me.chkemail.Value
-
Case "-1"
-
EAEcount = DCount("[type]", "WorkOrderTracking", "[type]")
-
Debug.Print [Type]; IIf(Me![email], "yes", "no");
-
Me.TotalTxt.Value = EAEcount
-
Me.Repaint
-
EAEcount = DCount("[type]", "WorkOrderTracking", "[Type] = 'Incident'")
-
Me.Inc_Text.Value = EAEcount
-
Me.Repaint
-
EAEcount = DCount("[type]", "WorkOrderTracking", "[Type] = 'Request'")
-
Debug.Print [Type];
-
Me.Req_Text.Value = EAEcount
-
Me.Repaint
-
EAEcount = DCount("[type]", "WorkOrderTracking", "[Type] = 'Change Order'")
-
Debug.Print [Type];
-
Me.CO_Text.Value = EAEcount
-
Me.Repaint
-
Case Else
-
Select Case Me.chkemail.Value
-
Case "Incident"
-
EAEcount = DCount("[Type]", "workordertracking", "[type] = 'Incident'")
-
Me.Inc_Text.Visible = True
-
Me.Req_Text.Visible = False
-
Me.CO_Text.Visible = False
-
Me.chkWrA.Visible = False
-
Me.Inc_Text.Value = EAEcount
-
Me.TotalTxt.Visible = False
-
Case "Request"
-
EAEcount = DCount("[Type]", "workordertracking", "[type] = 'Request'")
-
Me.Inc_Text.Visible = False
-
Me.Req_Text.Visible = True
-
Me.CO_Text.Visible = False
-
Me.chkWrA.Visible = False
-
Me.Req_Text.Value = EAEcount
-
Me.TotalTxt.Visible = False
-
Case Else
-
EAEcount = DCount("[Type]", "workordertracking", "[type] = 'Change Order'")
-
Me.Inc_Text.Visible = False
-
Me.Req_Text.Visible = False
-
Me.CO_Text.Visible = True
-
Me.chkWrA.Visible = False
-
Me.CO_Text.Value = EAEcount
-
Me.TotalTxt.Visible = False
-
End Select
-
End Select
-
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.
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: - Select Case Me.chkemail.Value
-
Case "Incident"
-
Case "Request"
-
End Select
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: - 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.
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)>
Assuming [email] is a Yes/No Field in the WorkOrderTracking Table, then I see no reason why the following Statement will not work: - EAEcount = Dcount("[Type]", "WorkOrderTracking", "[Type] = 'Incident' and [email] = True")
Thanks, that is exactly what I needed. "True" was the value I was looking for.
Thanks again.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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
|
by: Christian Blackburn |
last post by:
Hi Gang,
I'm wondering what the VB6 equivalent of Debug.Print is?
Thanks in Advance,
Christian Blackburn
|
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...
|
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?
|
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...
|
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...
|
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?
...
|
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")...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
| |