Solved

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

Posted on 2009-04-05
3
501 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

746 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