Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a dataform that stores two dates. One is called originaldate and one is nextdate. If the originaldate is null I want to be able to enter a date but I don't want to be able to change an existing date. I was thinking about adding something to the afterupdate that checks if the field is null. Two questions, is this the simplest way to do this and what code would you use to restore the originaldate (similiar to pressing esc button).

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I wouldn't try to undo data entry. I'd lock the text box bound to the originaldate field if it is not empty in the After Update event. You also have to do this in the On Current event of the form, so that the text box is locked/unlocked correctly when the user moves from record to record:

    Code:
    Private Sub Form_Current()
      Me.OriginalDate.Locked = Not IsNull(Me.OriginalDate)
    End Sub
    
    Private Sub OriginalDate_AfterUpdate()
      Me.OriginalDate.Locked = Not IsNull(Me.OriginalDate)
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is this possible with a datasheet style form?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Yes, the code that I posted should work whatever type of form you use - single, continuous or datasheet.

  5. #5
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm getting a Compile Error: Method or Member not found and .Locked is highlighted. Any reason? Thanks.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    What is the name of the text box bound to the originaldate field (I presume that you do have such a text box)?

  7. #7
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oops, the Name the of the textbox was Original Date (with a space). Works now, thanks.

Posting Permissions

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