Duplicate record command button not working

  • Thread starter Thread starter TRob
  • Start date Start date
T

TRob

I have created a command button on a form using the
command button wizard. This button duplicates the
existing record. For the most part, it works. However, I
see now that a date field is not duplicating properly.

For example, the original record shows the date of
01/07/04. The resulting duplicated record will show a
date of 01/07/2020!

Any hints what may be wrong? The date field has an input
mask on the form, 99/99/00;0;_, and the table stores the
date data in yyyymmdd format. Perhaps something wrong
there? I have tried numerous combinations and have even
taken out the input mask. Nothing works.

Thanks!
 
Post relevant details of your Table / your Form and code for the
CommandButton_Click Event.
 
I found that by taking out the "yyyymmdd" format in the
field in the table, the command button works and
duplicates the date properly.

However, I now run into a problem on the date format. I
must somehow be able to export data from this field using
the format "yyyymmdd". I have tried to specify this
format in the field definition in the query that I will be
using for the export. It doesn't seem to work. The
resulting exported text file still shows "1/7/04 0:00:00"
or "1/7/04".

The field on the form that was used to input the date uses
the input mask, 99/99/00;0;_, But when I remove the
input mask and all formatting in the form and table, I get
an error message, "The value you entered isn't valid for
this field...."


I think the duplicating command button is OK now, but for
what its worth, here is the command button code:
-------------------------------------------------
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, ,
acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, ,
acMenuVer70 'Paste Append

Exit_Command216_Click:
Exit Sub

Err_Command216_Click:
MsgBox Err.Description
Resume Exit_Command216_Click
-------------------------------------------------
 
Create a Calculated Filed in your Query:

FormattedDate: Format([DateField], "yyyymmdd")

and use this Calculated Field for export rather than the original DateField.
 
It worked! Now I've learned something new. I may have to
apply the same logic to other fields in my extract that
I'm having trouble with. And how simple. Why didn't I
think of that?

Thanks!
-----Original Message-----
Create a Calculated Filed in your Query:

FormattedDate: Format([DateField], "yyyymmdd")

and use this Calculated Field for export rather than the original DateField.

--
HTH
Van T. Dinh
MVP (Access)



I found that by taking out the "yyyymmdd" format in the
field in the table, the command button works and
duplicates the date properly.

However, I now run into a problem on the date format. I
must somehow be able to export data from this field using
the format "yyyymmdd". I have tried to specify this
format in the field definition in the query that I will be
using for the export. It doesn't seem to work. The
resulting exported text file still shows "1/7/04 0:00:00"
or "1/7/04".

The field on the form that was used to input the date uses
the input mask, 99/99/00;0;_, But when I remove the
input mask and all formatting in the form and table, I get
an error message, "The value you entered isn't valid for
this field...."


I think the duplicating command button is OK now, but for
what its worth, here is the command button code:
-------------------------------------------------
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, ,
acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, ,
acMenuVer70 'Paste Append

Exit_Command216_Click:
Exit Sub

Err_Command216_Click:
MsgBox Err.Description
Resume Exit_Command216_Click


.
 
TRob I think you can help Me!!

I am using Duplicate Record command button. I do I make it stop going to the previous record when I click in a field on the newly created duplicated record

It always reverts back to the previous record.
 
Back
Top