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

Checkbox filled if another field is not null

114 100+
Hello,
In a report, for every record, I would like a checkbox to appear checked if a certain field contains any value.

The field is Client_comments. (memo field)
I added a checkbox called CkComments and added the following vba to the report code.
Expand|Select|Wrap|Line Numbers
  1. Private Sub CkComments_Load()
  2. If IsNull(Client_comments) = False Then
  3. CkComments = True
  4. Else CkComments = False
  5. End If
  6. End Sub 
When I open the report, the checkboxes are empty regardless of what data is in Client_comments.

I'm not sure if this is the right way to accomplish what I am looking for so any help is much appreciated. Thank you!
martin
Oct 26 '07 #1
3 5168
Jim Doherty
897 Expert 512MB
Hello,
In a report, for every record, I would like a checkbox to appear checked if a certain field contains any value.

The field is Client_comments. (memo field)
I added a checkbox called CkComments and added the following vba to the report code.
Expand|Select|Wrap|Line Numbers
  1. Private Sub CkComments_Load()
  2. If IsNull(Client_comments) = False Then
  3. CkComments = True
  4. Else CkComments = False
  5. End If
  6. End Sub 
When I open the report, the checkboxes are empty regardless of what data is in Client_comments.

I'm not sure if this is the right way to accomplish what I am looking for so any help is much appreciated. Thank you!
martin
You are just as well off basing your report on a query and placing that IF logic in an IIF function as a virtual column in the data. That way your column becomes a calculate data field and available to the report 'before' it opens whereas 'as is' it must try and manipulate on formatting for print. Not everything is available always for changing on the fly when you open a report like that (textboxes for instances are one of them) I nearly always where possible make my query do the work on issues such as these. (which gives you the benefit of simply amending the query should any logic change without having to revisit the report).

Try placing this in the query grid for your report as a calculated field

Expand|Select|Wrap|Line Numbers
  1.  CkComments: IIF(IsNull(Client_Comments),True,False)
The field then will be available for your to CkComments to bind to

Hope this helps

Jim :)
Oct 26 '07 #2
martin DH
114 100+
I must have given it to you backwards. Just switching the True and False worked exactly as planned though. Thanks, Jim!

Expand|Select|Wrap|Line Numbers
  1. IIf(IsNull([Client_Comments]),False,True) AS CkComments
martin
Oct 26 '07 #3
Jim Doherty
897 Expert 512MB
I must have given it to you backwards. Just switching the True and False worked exactly as planned though. Thanks, Jim!

Expand|Select|Wrap|Line Numbers
  1. IIf(IsNull([Client_Comments]),False,True) AS CkComments
martin
You're welcome

Jim :)
Oct 26 '07 #4

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

Similar topics

0
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
3
by: Jack | last post by:
<i><input type="checkbox" name="chk_Complete" value="TRUE" <%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked" Else Response.Write " unchecked"%>> The above...
17
by: jdph40 | last post by:
Question 1: In Access 97, I have a form (frmVacationWeeks) with a subform (sbfrmPostVacDates). The subform can have up to 33 records and each record has 2 checkboxes, one for approved and one for...
7
by: Tony Williams | last post by:
I have a check box called Loadtxt and when it is ticked I want the value of a control called EmailDatetxt to be today's date. I am using this code in the AfterUpdate event of the checkbox but it...
6
by: Megan | last post by:
Hi everybody- I'm trying to use a checkbox to control whether or not a date field in a query "Is Null" or "Is Not Null." I have 2 date fields: InDate and OutDate. If there is an OutDate, then...
2
by: Kapil Jain | last post by:
Dear All, Please assist me for below code : What i need is -> One "Patient Master" form for online Entry : My AIM -> When somebody want to add new patient a parent form will open than finally...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
7
by: bgaye1979 | last post by:
I have a form and there is a Yes/No Checkbox as a datatype. This field is called FileReturned. There is another field called ReturnedDate. If the ReturnedDate field is Null, I want the checkbox...
13
by: PhpCool | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.