1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Help with Access

Discussion in 'Business Applications' started by hotdiamond, Jan 24, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. hotdiamond

    hotdiamond Thread Starter

    Joined:
    Mar 4, 2004
    Messages:
    161
    I have a form in which there is a text field called "site visit" and the user can choose from a drop down list yes or no, depending on whether or not a site visit is required. If a site visit is required and yes is selected, then the user must enter the date of the visit in the next field "Date of Site Visit". However, if no site visit is required, the date field is left blank. Is it possible to create a default value for the "Date of Site Visit" field so that it's populated with an alternate date or number when "Site Visit" is left null or no is selected? This will help ensure that the field was not left blank in error. If this is possible, please help as I'm not very good at writing code.

    Thanks in advance.
     
  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    I think it would be better to ensure that the Date is filled in correctly by the user if the Yes is selected.
    To do so some simple VBA code can be used in the Form's "On Dirty" event procedure.
     
  3. hotdiamond

    hotdiamond Thread Starter

    Joined:
    Mar 4, 2004
    Messages:
    161
    That does make sense. However, my supervisor is actually requesting that no field be left blank in the form. So that is why I'm trying to either make the field default with Null/No or have the user manually enter a specific value to indicate the answer was NO (such as 99/99/9999). Although, since it is a date field, 99/99/9999 would probably not be allowed. So is it possible to create a default and how difficult would it be?
     
  4. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    It is easy to create a default, you just use the Default Value, 01/01/1900 would probably be best.
    However please explain to your supervisor that fields with data in tend to get ignored by users as it already has a date in it.
    You could still use the VBA validation of course.
    Another alternative is to have the field as plain text on the form showing "No Data" or something similar and store the date in another field only when a valid date is entered in the text field.
    Or you could hide the date field until they click the Yes option.
     
  5. hotdiamond

    hotdiamond Thread Starter

    Joined:
    Mar 4, 2004
    Messages:
    161
    Okay, so I think what I would like to do is when no is selected in the site visit field, then I'd like the date of site visit field to populate with 01/01/1900. Can you help me with the coding for this please?
     
  6. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Just set the Field's Default Value Property to
    01/01/1900
    All new records should then have 01/01/1900 as the field value, if you need to change all the old records you will need an Update query to do that.

    I would still recommend some VBA to test of the combo is Yes then a different date is needed in the field.
     
  7. hotdiamond

    hotdiamond Thread Starter

    Joined:
    Mar 4, 2004
    Messages:
    161
    I changed the default value of the field to 01/01/1900 but it's still not populating. The field is still showing as empty. Shouldn't it show the default value in the form? Also, I would like to add the VBA for the combo Yes too. Can you help with this?
     
  8. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    You will probably find that the default only works with new records, have you tried that?
    I can help you with the VBA code.
     
  9. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1086671

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice