Update field when click button

V

viddom

I wrote this code when I click a selection field, but it does not work.Can
you tell me where do I have the mistake?

Private Sub AttendClick_Click()
If Me.AttendClick = True Then
'Here the field Regist-Datum must be updated to the current date
Me.[Regist-Datum] = Date
Else
'Here the field Regist-Datum must be empty
Me.[Regist-Datum].Value = ""
End If
End Sub
 
J

Jeff Boyce

You haven't explained what does happen, only that "it does not work". How
it doesn't work could be helpful in diagnosing what is not working.

One thought, have you tried using "Null" instead of "" ...
'Here the field Regist-Datum must be empty
Me.[Regist-Datum] = Null

Regards

Jeff Boyce
<Access MVP>

viddom said:
I wrote this code when I click a selection field, but it does not work.Can
you tell me where do I have the mistake?

Private Sub AttendClick_Click()
If Me.AttendClick = True Then
'Here the field Regist-Datum must be updated to the current date
Me.[Regist-Datum] = Date
Else
'Here the field Regist-Datum must be empty
Me.[Regist-Datum].Value = ""
End If
End Sub
 
R

Rick B

What do you mean "it does not work"? What does it do?

Current date is Date(), not Date.
Me.[Regist-Datum] = Date()

Why do you use Me.[Regist-Datum] = in one statement and
Me.[Regist-Datum].Value = in the other statement?
 
V

viddom

Dear Rick B,
the goal is to put the current date in the field [Regist-Datum] when
"AttendClick" is true, but when I click the button the date do not appear in
the field.

When I type DATE() my VBA editor change it to DATE

I retyped the code and looks like this

Private Sub AttendClick_Click()
If Me.AttendClick = True Then
Me.[Regist-Datum] = Date
Else
Me.[Regist-Datum] = Null
End If
End Sub

But still do not execute the task.What else do I have to do?

Note:I am new using code


Rick B said:
What do you mean "it does not work"? What does it do?

Current date is Date(), not Date.
Me.[Regist-Datum] = Date()

Why do you use Me.[Regist-Datum] = in one statement and
Me.[Regist-Datum].Value = in the other statement?


--
Rick B



viddom said:
I wrote this code when I click a selection field, but it does not work.Can
you tell me where do I have the mistake?

Private Sub AttendClick_Click()
If Me.AttendClick = True Then
'Here the field Regist-Datum must be updated to the current date
Me.[Regist-Datum] = Date
Else
'Here the field Regist-Datum must be empty
Me.[Regist-Datum].Value = ""
End If
End Sub
 
R

Ronald Roberts

viddom said:
Dear Rick B,
the goal is to put the current date in the field [Regist-Datum] when
"AttendClick" is true, but when I click the button the date do not appear in
the field.

When I type DATE() my VBA editor change it to DATE

I retyped the code and looks like this

Private Sub AttendClick_Click()
If Me.AttendClick = True Then
Me.[Regist-Datum] = Date
Else
Me.[Regist-Datum] = Null
End If
End Sub

But still do not execute the task.What else do I have to do?

Note:I am new using code


:

What do you mean "it does not work"? What does it do?

Current date is Date(), not Date.
Me.[Regist-Datum] = Date()

Why do you use Me.[Regist-Datum] = in one statement and
Me.[Regist-Datum].Value = in the other statement?


--
Rick B



I wrote this code when I click a selection field, but it does not work.Can
you tell me where do I have the mistake?

Private Sub AttendClick_Click()
If Me.AttendClick = True Then
'Here the field Regist-Datum must be updated to the current date
Me.[Regist-Datum] = Date
Else
'Here the field Regist-Datum must be empty
Me.[Regist-Datum].Value = ""
End If
End Sub

I think all you need is below. If you click the button AttendClick,
the Sub AttendClick_Click() will fire which means it is true.

Private Sub AttendClick_Click()
Me.[Regist-Datum] = Date
End Sub

Ron
 
R

Rick B

AHHHHH I thought it was a checkbox, not a button.

Makes more sense now.


--
Rick B



Ronald Roberts said:
viddom said:
Dear Rick B,
the goal is to put the current date in the field [Regist-Datum] when
"AttendClick" is true, but when I click the button the date do not appear in
the field.

When I type DATE() my VBA editor change it to DATE

I retyped the code and looks like this

Private Sub AttendClick_Click()
If Me.AttendClick = True Then
Me.[Regist-Datum] = Date
Else
Me.[Regist-Datum] = Null
End If
End Sub

But still do not execute the task.What else do I have to do?

Note:I am new using code


:

What do you mean "it does not work"? What does it do?

Current date is Date(), not Date.
Me.[Regist-Datum] = Date()

Why do you use Me.[Regist-Datum] = in one statement and
Me.[Regist-Datum].Value = in the other statement?


--
Rick B




I wrote this code when I click a selection field, but it does not work.Can
you tell me where do I have the mistake?

Private Sub AttendClick_Click()
If Me.AttendClick = True Then
'Here the field Regist-Datum must be updated to the current date
Me.[Regist-Datum] = Date
Else
'Here the field Regist-Datum must be empty
Me.[Regist-Datum].Value = ""
End If
End Sub

I think all you need is below. If you click the button AttendClick,
the Sub AttendClick_Click() will fire which means it is true.

Private Sub AttendClick_Click()
Me.[Regist-Datum] = Date
End Sub

Ron
 
Top