date edit

awake2424

Registered User.
Local time
Today, 10:15
Joined
Oct 31, 2007
Messages
479
I have a field on a form that when a check box is checked then the date is populate in a AddDate field. The problem is if the user edits that field the changes do not save. Below is some of the code, how do I save the changes? Thanks.

Code:
 Me.AddDate = Date
If Me.Dirty Then    'Save any edits.
        Me.Dirty = False
 
The text box that displays the date (Me.AddDate) needs to be bound to a field in the forms record source (table/query)
 
Me.AddDate is bound to a field called AddDate. The problem is if the user check the box the AddDate will be automatically set to 8/22/2014. If the user changes that date manually to 8/11/2014 and goes to the next record the change does not save and AddDate is still 8/22/2014. Thank you.
 
What is the Control Source property setting of the text box called AddDate
 
The control Source is set to AddDate in the field. Thanks.
 
The control Source is set to AddDate in the field. Thanks.
Then the value entered by the user should be saved to the field in the table.
Which event has the code you posted earlier.
Do you have any other code which could be changing the value that is entered by the user.
 
Here is the complete code:

Code:
 Private Sub Form_Current()
    Me.Check275.Visible = Not IsNull(Me.Text246)

If Me.Check295 = -1 Then
        Me.Text281.Visible = True
        Me.Text285.Visible = True
        Me.Text287.Visible = True
        Me.Text289.Visible = True
        Me.AddDate.Visible = True
        Me.AddDate = Date
        Me.Text298.Visible = True
        Me.Text300.Visible = True
        Me.Text306.Visible = True
If Me.Dirty Then    'Save any edits.
        Me.Dirty = False
    End If
    
    Else
        Me.Text281.Visible = False
        Me.Text285.Visible = False
        Me.Text287.Visible = False
        Me.Text289.Visible = False
        Me.AddDate.Visible = False
        Me.Text298.Visible = False
        Me.Text300.Visible = False
        Me.Text306.Visible = False
        Me.Text281.Value = Null
        Me.Text285.Value = Null
        Me.Text287.Value = Null
        Me.AddDate.Value = Null
        Me.Text298.Value = Null
        Me.Text300.Value = Null
        Me.Text306.Value = Null
    End If
End Sub
Private Sub Check295_AfterUpdate()
If Me.Check295 = -1 Then
        Me.Text281.Visible = True
        Me.Text285.Visible = True
        Me.Text287.Visible = True
        Me.Text289.Visible = True
        Me.AddDate.Visible = True
        Me.AddDate = Date
        Me.Text298.Visible = True
        Me.Text300.Visible = True
        Me.Text306.Visible = True
If Me.Dirty Then    'Save any edits.
        Me.Dirty = False
    End If
    
    Else
        Me.Text281.Visible = False
        Me.Text285.Visible = False
        Me.Text287.Visible = False
        Me.Text289.Visible = False
        Me.AddDate.Visible = False
        Me.Text298.Visible = False
        Me.Text300.Visible = False
        Me.Text306.Visible = False
        Me.Text281.Value = Null
        Me.Text285.Value = Null
        Me.Text287.Value = Null
        Me.AddDate.Value = Null
        Me.Text298.Value = Null
        Me.Text300.Value = Null
        Me.Text306.Value = Null
    End If
End Sub
Thanks.
 
Can't see the need for the line of code:
Me.AddDate = Date
in the forms On Current event. That will change the date back to "todays" date whenever the record is shown.
 

Users who are viewing this thread

Back
Top Bottom