Command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to create a button on a form that will populate the form and the
table with the date and time. I am what the best way on how to create this
task
 
In the button's OnClick event just put something like...

[SomeFieldName] = Now()

Not sure a button is the way to go on this. You can have the date and time
fill in automatically when the record is added.

You'd have to give us more details if you want a more detailed answer.



Rick B
 
Hi, Steve.

Assuming a textbox named txtDate is Bound to a Date/Time field in the form's
underlying table, this should do it:

Sub cmdStampTime_Click()
txtDate = Now()
End Sub

Format the textbox as General Date to show both the date and time.

HTH
Sprinks
 
What I would like to have happen on the form is you would click on a button
and it would popultate the date and time on the form as well as in the table.
The 2 suggestions that have been made do not work.
 
Steve,

What you're experiencing is a common misunderstanding about what forms are
and how they work. To explain, forms themselves can be Bound or Unbound. If
they're Bound, their Record Source property which will specify the name of a
table or query. All forms in which you plan to enter data into tables
through the use of a form will be of this type.

Unbound forms do not have a Record Source. They have many uses; I often use
them to permit a user to enter multiple selection criteria prior to printing
a custom report. Based on their input, I build an SQL string that is used to
filter the report (or more properly, the report's underlying query).

On forms, you place *controls*--textboxes, combo boxes, checkboxes, etc.
These may also be Bound or Unbound. If a control is Bound to a field, what
is entered into it is automatically entered into the field to which it is
bound, which necessarily a field in the form's underlying Record Source.
This is set by the control's Control Source property.

So, if pressing the command button enters data into the control, but does
not store it in your field, it must be that your textbox is not Bound to the
field. To do this, open the form in design view, click on the field, show
the Properties window (View, Properties or right-click, Properties), and
change the Control Source to the name of your field.

If the field is not present in the drop-down list, it is not in table or
query specified in the form's Record Source. This is also a frequent issue.
If a form is based on a query, and a user adds a field to one of the query's
tables, it must also be added to the query for it to show up in the list.
Perfectly logical, since the QUERY, not the table, is the form's Record
Source.

Hope that resolves your issue.

Sprinks
 
Back
Top