473,326 Members | 2,147 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,326 software developers and data experts.

Me.Checkbox Script in VB

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 to be unchecked automatically, else the checkbox should be checked. Can someone help me with the code and where to write it? Should it be on the form's current event or before update?

Here's it what i have?

If ReturnedDate is Null Then
Me.FileReturned= False
Else
Me.FileReturned=True
End If
Nov 5 '07 #1
7 4645
benchpolo
142 100+
You can place the code in several event OnFormLoad, OnBeforeUpdate, OnAfterUpdate, OnClick, OnDoubleClick, OnFocus, OnLostFocus depending on the requirements on your specs.
Nov 5 '07 #2
You can place the code in several event OnFormLoad, OnBeforeUpdate, OnAfterUpdate, OnClick, OnDoubleClick, OnFocus, OnLostFocus depending on the requirements on your specs.
Thank you. I did but the code didn't work. Any idea?
Nov 5 '07 #3
zimitry
11
There's a few ways todo this here's one...

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtbox1_AfterUpdate()
  2.  
  3.     If IsNull(Me.txtbox1) And Me.chkbox1 = True Then
  4.         Me.chkbox1.Value = False
  5.     Else
  6.         'Do nothing
  7.     End If
  8.  
  9. End Sub
  10.  
  11. Private Sub txtbox1_Exit(Cancel As Integer)
  12.  
  13.     If IsNull(Me.txtbox1) And Me.chkbox1 = True Then
  14.         Me.chkbox1.Value = False
  15.     Else
  16.         'Do nothing
  17.     End If
  18.  
  19. End Sub
  20.  
HTH

z
Nov 5 '07 #4
Thank you for the assistance. I tried it as you said but the checkbox is not updated( or checked automatically) for records where the ReturnedDate is Not Null with the code below;

Private Sub ReturnedDate_AfterUpdate()
If IsNull(Me.ReturnedDate) And Me.FileReturned = True Then
Me.FileReturned.Value = False
Else
'do nothing
End If
End Sub

Do you have any further assistance?


There's a few ways todo this here's one...

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtbox1_AfterUpdate()
  2.  
  3.     If IsNull(Me.txtbox1) And Me.chkbox1 = True Then
  4.         Me.chkbox1.Value = False
  5.     Else
  6.         'Do nothing
  7.     End If
  8.  
  9. End Sub
  10.  
  11. Private Sub txtbox1_Exit(Cancel As Integer)
  12.  
  13.     If IsNull(Me.txtbox1) And Me.chkbox1 = True Then
  14.         Me.chkbox1.Value = False
  15.     Else
  16.         'Do nothing
  17.     End If
  18.  
  19. End Sub
  20.  
HTH

z
Nov 5 '07 #5
lee123
556 512MB
hi there you want to put this code in the forms current event like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3.     If IsNull(returneddate) Then
  4.         filereturned = False
  5.     Else
  6.         filereturned = True
  7.  
  8.     End If
  9.  
  10. End Sub
i hope this is what you were trying to do.

lee123
Nov 6 '07 #6
Thank you so much. It worked perfectly fine.
hi there you want to put this code in the forms current event like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3.     If IsNull(returneddate) Then
  4.         filereturned = False
  5.     Else
  6.         filereturned = True
  7.  
  8.     End If
  9.  
  10. End Sub
i hope this is what you were trying to do.

lee123
Nov 6 '07 #7
lee123
556 512MB
glade to help

lee123
Nov 6 '07 #8

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...
4
by: Matt | last post by:
In ASP page, there is a "SELECT ALL" button, when user click it, it will select all checkboxes. I am not sure should I use client-side code to do that? the following is my approach but it didnt...
4
by: Fabri | last post by:
How can I, on button click, to select ONLY the following 4 checkbox? I would like to do this without a for loop through form.lenght because this is only an example and I have to apply this script...
5
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.......
2
by: UJ | last post by:
Is there a way with a asp:checkbox to run a JavaScript to display/hide text/input on the screen without doing a postback? I also need to be able to access the stuff at the server so I need to...
0
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
0
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
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...
1
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...
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
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.