Solved

autofill field 1 with "Yes" if date field not null

Posted on 2009-04-05
3
503 Views
Last Modified: 2012-05-06
There are two fields: Orientation Yes/No (but I'm using TEXT not a check box) and Orientation DAte.  The default value for Orientation is "No".  How can I have that automatically change to "Yes" if a date is entered in the Orientation date field?  The client would like most viewers to see only Yes/No.  THanks.
0
Comment
Question by:schneider_ks
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 250 total points
ID: 24071793
so is this on the entry of a date? if so then use the afterupdate event. this is triggered each time you change the value

find your date in form design, look at its properties, go to events tab then click on the button for afterupdate then select code builder
say your control was called orientation_date and orientation (which you say is text so you want either yes or no displayed)


private sub orientation_date_afterupdate()

    'Check if date entered, if so set to yes
    if nz(me.orientation_date,"") <> "" then
        me.orientation = "Yes"
    else
        me.orientation = "No"
    end if
end sub

0
 

Author Closing Comment

by:schneider_ks
ID: 31566778
Excellent, Thanks so much
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24071990
No probs.

fyi, not telling you to do this, just some advice from me

You know, its probably better to use a yesno control. You can always use code to display YesNo on a label perhaps. Say u had a label called lblYesNo, you set the text of it by using the Caption property

lblYesNo.Caption = "Yes"

Other thing is its recommended not to store calculated fields in a db. Given a date field, you can always determine this yesno either in a query or a form (like using
the label example)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now