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

How to clear Date Field if another field is null

I have a form which has (Signed_Out) & (Allocated_Date_Time) Fields. I am attempting to clear the allocated_Date_Time field when I clear the Signed_Out.

I currently have below code to auto insert date/time on entry f Signed_Out which is working well. How do I add to this in order to do above request?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Signed_Out_AfterUpdate()
  2.     Me.Allocated_Date_Time = Now()
  3. End Sub

Thanks Ross
Mar 20 '19 #1
1 1670
twinnyfo
3,653 Expert Mod 2GB
Rossco73,

Welcome to Bytes!

First, some requirements, then some advice, then a proposed solution.

Requirement: Please use code tags when you post code to the forum (the [CODE/] button in your post editor).

Advice: It is always highly recommended that you rename the controls on your form to something other than "merely" the underlying field name. Yes, this is a default of MS access, but I think MS has failed here. When you have a text box named Allocated_Date_Time that refers to an underlying field with the same name, when you refer to this field/control, this can be ambiguous for the DB. You always want to be explicit, not vague. So, I would recommend you rename these controls to txtAllocated_Date_Time and chkSigned_Out (I am making an assumption that this is a Yes/No field and you have a Check Box control--based upon context it would make sense. If not, then we will have to modify the proposed solution below.

Proposed Solution: It appears that when you check out an item, you are recording the date it is checked out. Then, when it is checked back in, you clear out the date. Again, assumptions, because you have provided very little information on this. So, if this is the case, then you want to check the value of your chkSigned_Out control to determine what you are going to do with the date control. See below:
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkSigned_Out_AfterUpdate()
  2.     Me.txtAllocated_Date_Time = _
  3.         IIf(chkSigned_Out, _
  4.             Now(), _
  5.             Null)
  6. End Sub
As you can see, this code assiigns a value to txtAllocated_Date_Time, but it first checks the value of your Check Box. If the check box is checked, it assigned the current Date/Time. If it is unchecked, it clears the text box.

Hope this hepps.
Mar 20 '19 #2

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

Similar topics

6
by: Greg | last post by:
I am trying to change the value of one field in my query based on the value in another. If Field 1 had the text "ONACCNT" then in Feild 2 I want the date to change to today's date. Any help would...
1
by: Liz Malcolm | last post by:
Hello and TIA. I have a DE form with an option group that if daily is selected todays date is used for start and end date, if weekly is selected Monday - Friday is used. I am trying to add a...
1
by: Olly | last post by:
I need a date validation that will not allow a date to be entered in the field if it occurs before a date in another field (StartDate). But I cannot find any information on how to do this. Olly
10
by: satishrajana | last post by:
Hi, My SQL returns a NULL in a datefield if there is no date in that field. If there is a NULL in this column, I want to replace it with spaces in my SELECT statement when I am selecting these...
8
by: billyqgoat | last post by:
Hi!! In my table, I have two fields that will be filled with the same date (but I need both fields). So that the person entering the data doesn't need to enter the same date twice, I've been trying...
2
by: Coll | last post by:
I have a field that I would like to display on a report only if the value of another field matches a certain criteria. If it does match I need the label & the field value to display (though I'm...
3
by: Finn Stampe Mikkelsen | last post by:
Hi I have defined a table in my database, with 2 date-fields. I have set a default value to DBNull. I have integrated a nullable datetimepicker control to my project and set the apropriate...
4
by: Dr Al | last post by:
I have a project which requires the batch import of customer contact information, print mailing labels for those customers who have their date of first letter field in the database set to null, and...
1
by: Donna Wiley | last post by:
I have a date field that could be formatted m/d/yyyy, mm/d/yyyy, m/dd/yyyy, or mm/dd/yyyy. I need to be able to enter a start date and an end date in a parameter query, i.e. Between (date) and...
5
by: nhonelove | last post by:
I can't remember how to populate one field when another field has been updated/populated. Any help would be greatly appreiciated. Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.