How can I automate the CNTR + " to repeat the data in field / reco

G

Guest

I am doing dataentry and have to repeat into each record the same date and
would like the date of the record above to be repeated
 
F

fredg

I am doing dataentry and have to repeat into each record the same date and
would like the date of the record above to be repeated

If the field is a Date datatype, code that control's Afte4rUpdate
event:

Me![DateField].DefaultValue = "#" & Me![DateField] & "#"

If the field is NOT a Date datatype, then you can use:

Me![ControlName].DefaultValue = """" & Me![ControlName] & """"

You'll have to enter the value just once per session.
It will remain the same until changed.
 
G

Guest

Thanks but forgive me for being thick, but this is for new users.
I entered into my [DatePaid] textbox formatted to short date in the
afterupdate on property
=Me![DatePaid].DefaultValue = "#" & Me![DatePaid] & "#"
but nothing happened. except
The expression After Update you entered as an event property setting
produced the following errer: the object doesn't contain the Automation
object 'Me.'.
I tried the other expression also be with similar results. Can you try again
please.

fredg said:
I am doing dataentry and have to repeat into each record the same date and
would like the date of the record above to be repeated

If the field is a Date datatype, code that control's Afte4rUpdate
event:

Me![DateField].DefaultValue = "#" & Me![DateField] & "#"

If the field is NOT a Date datatype, then you can use:

Me![ControlName].DefaultValue = """" & Me![ControlName] & """"

You'll have to enter the value just once per session.
It will remain the same until changed.
 
D

Douglas J. Steele

That's VBA code, and you can't just enter code as a property.

Go to the property and select [Event Procedure] from the pull-down list,
then hit the ellipsis (...) to the right. That will take you into the VB
Editor, in the middle of code like:

Private Sub DatePaid_AfterUpdate()

End Sub

Put that code inside that routine (without the initial equal sign)

Private Sub DatePaid_AfterUpdate()

Me![DatePaid].DefaultValue = "#" & Me![DatePaid] & "#"

End Sub

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Dennis said:
Thanks but forgive me for being thick, but this is for new users.
I entered into my [DatePaid] textbox formatted to short date in the
afterupdate on property
=Me![DatePaid].DefaultValue = "#" & Me![DatePaid] & "#"
but nothing happened. except
The expression After Update you entered as an event property setting
produced the following errer: the object doesn't contain the Automation
object 'Me.'.
I tried the other expression also be with similar results. Can you try
again
please.

fredg said:
I am doing dataentry and have to repeat into each record the same date
and
would like the date of the record above to be repeated

If the field is a Date datatype, code that control's Afte4rUpdate
event:

Me![DateField].DefaultValue = "#" & Me![DateField] & "#"

If the field is NOT a Date datatype, then you can use:

Me![ControlName].DefaultValue = """" & Me![ControlName] & """"

You'll have to enter the value just once per session.
It will remain the same until changed.
 
G

Guest

Thanks that worked - but the date format comes out usa style. The first entry
(off the pop up calendar) is NZ style ie 24/12/07 but repeats come out
12/24/07.
Database and O/S Regional are set to NZ
 
F

fredg

Thanks that worked - but the date format comes out usa style. The first entry
(off the pop up calendar) is NZ style ie 24/12/07 but repeats come out
12/24/07.
Database and O/S Regional are set to NZ

A Date control's Format is irrelevant to the way the date is actually
stored.
If you wish to format the date in any particular date format, set the
control's format property to what ever format you wish:
dd/mm/yy
will format the control to 24/12/07
 
F

fredg

Thanks but forgive me for being thick, but this is for new users.
I entered into my [DatePaid] textbox formatted to short date in the
afterupdate on property
=Me![DatePaid].DefaultValue = "#" & Me![DatePaid] & "#"
but nothing happened. except
The expression After Update you entered as an event property setting
produced the following errer: the object doesn't contain the Automation
object 'Me.'.
I tried the other expression also be with similar results. Can you try again
please.

fredg said:
I am doing dataentry and have to repeat into each record the same date and
would like the date of the record above to be repeated

If the field is a Date datatype, code that control's Afte4rUpdate
event:

Me![DateField].DefaultValue = "#" & Me![DateField] & "#"

If the field is NOT a Date datatype, then you can use:

Me![ControlName].DefaultValue = """" & Me![ControlName] & """"

You'll have to enter the value just once per session.
It will remain the same until changed.

I suspect you wrote the expression directly on the control's
AfterUpdate line. That is not correct.

Here is how to write code.

Open the Form in Design View.
Select the DatePaid control.
Display the DatePaid Property sheet.
Click on the Event tab.
On the line that says AfterUpdate, write:
[Event Procedure]
Then click on the little button with the 3 dots that appears on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines, write:

Me![DatePaid].DefaultValue = "#" & Me![DatePaid] & "#"

Note that there is NO leading = sign.
Save the changes.

Note: The value of a date datatype field is the count of the number of
days since December 30, 1899. Today's date would be stored as 39321.

You can then format the date to display in any Access recognized date
format.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top