Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2010
    Posts
    8

    Unanswered: Blank date on form, but updates table to todays date?

    Hi all
    I have a question - I have a form (frmIncMaster) for the table (tblIncMaster). The form has options such as Community, type of Incident, location of incident etc. with the date that automatically shows today’s date.
    If you change the date on the form, it updates the table. It has default to show today's date when you enter a new record.
    What has been requested and I need to do is, that the date be blank (on the form) and optional to enter it, and if you leave it blank, the table still inputs to today’s date otherwise it updates the date you entered on form.

    I know how to unbound the date on the form (making date entry optional), is there a formula to print todays Date() on table, if the form doesn't get a date entered?

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by leegun View Post
    ...I know how to unbound the date on the form (making date entry optional),
    'Unbounding' the the control doesn't make data entry optional, it makes it unbound, i.e. it's not 'attached' to a field in your underlying table!

    What you can do is simply assign the current date if no date has been entered just prior to the record being saved, using the Form_BeforeUpdate event:
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
     If Nz(Me.YourDate, "") = "" Then
      Me.YourDate = Date
     End If
    End Sub
    where YourDate is the control in question.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Dec 2010
    Posts
    8
    So will the date on the form be blank with this code?
    btw I cant test until Monday.

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    It will be blank, until the record is saved, allowing for manually entry of a date, if desired. Once the record is saved, i.e. on closing the form or moving to a different record, the current date will be inserted into the record in the table. If the saved record is lateraccessed the date will then appear on the form.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Dec 2010
    Posts
    8
    Sounds good thanks.
    I will test it at work tomorrow and get back to you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •