Question: How to copy a date

ramasule

Registered User.
Local time
Today, 05:20
Joined
Mar 13, 2007
Messages
33
I wish to do this

Newdate = Olddate

I have tried that and
Olddate = 03/03/2003
oldate = cdate(03/03/2003)

Im missing something.

Thanks, Derek L
 
Olddate = #03/03/2003#
oldate = cdate("03/03/2003")
 
:/
That didnt work either
Heres the code


Private Sub Command52_Click()
On Error GoTo Err_Command42_Click

'Goal* To copy DateExpired into OrigDateExpired then give new expiry
'OrigDateExpired = CDate("2/3/2007") tried did not work
'OrigDateExpired = DateExpired tried did not work
'OrigDateExpired = #03/03/2003# tried did not work
DateExpired = CDate(InputBox("Enter New Expiry Date", "Expiry Date"))

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub

Anysuggestions
 
When you "say it didn't work", does it report an error? Does *anything* happen? Are these bound control on a form? If so, what are the DataTypes of the fields to which they are bound?
 
No error
Goes to the InputBox

Has a text box in the form to display value tried with box enabled/notlocked and disabled/locked
Datatype is Date/Time same as expirydate
 
I think we're suffering from a lack of information. In your first post you seem to have asked how to assign a date to a variable, or something. Then, went through and said that things didn't work, but now you say "No error Goes to the InputBox."

Maybe you should post the whole part of the code that is related, so we can see what you're trying to accomplish and also say what it is that is happening (or NOT happening) so we can know what the problem really is.

Thanks, that would help.
 
What I posted above is the whole code part
I click a button and I wish it to do what I had posted.

Tommorow I will try to upload that page or something.

Tonight I will fool around with it some more.

Thanks for anytime you spent on replying,

Derek L
 
What is OldDate and what is NewDate? Where are the values coming from and how have you declared the variables?
 
TBL Project1
DateExpired Date/Time, (user enters)
OrigDateExpired Date/time, (copies date expired)

Form
2 textboxes
1 textbox DateExpired
1 textbox OrigDateExpired

1 button code is
On Click ...
Private Sub Command52_Click()
On Error GoTo Err_Command42_Click

'Goal* To copy DateExpired into OrigDateExpired then give new expiry
'OrigDateExpired = CDate("2/3/2007") tried did not work
'OrigDateExpired = DateExpired tried did not work
'OrigDateExpired = #03/03/2003# tried did not work

OrigDateExpired = DateExpired
DateExpired = CDate(InputBox("Enter New Expiry Date", "Expiry Date"))

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub


The date expired part works fine.

It just wont copy into orig dateexpired.
 
you just want the form to show the new date in the input box?
 
No I cant get the button to ..

copy the new date and put it in the old date

OrigDateExpired = DateExpired

This part is fine

DateExpired = CDate(InputBox("Enter New Expiry Date", "Expiry Date"))
 
I would love to but I am on a 3kb/s connection and It takes me 5 trys just to post a quick reply.

I know the code works because I tried it in a blank database

I have noticed when I try to do a
Me.OrigDateExpired it does not show up.

Does the table have to be relinked ot the form or something of that sort?
 
Code:
On Error GoTo Err_Command4_Click

Me.OrigDateExpired.Value = Me.DateExpired.Value
DateExpired = CDate(InputBox("Enter New Expiry Date", "Expiry Date"))

Exit_Command4_Click:
Exit Sub

Err_Command4_Click:
MsgBox Err.Description
Resume Exit_Command4_Click
That changed for me!
is the data not being written to the table? is that the problem?
 
I have no doubt it works.
It seems right now my form does not see OrigDateExpired
When I use Me.OrigDateExpired
gives me
Method or Data Member not found.

Is there someway this lost its link to my table. ..
all the other fields work just not this one.
 
Okay, I think we just stumbled upon your problem. You need to assign the variable to a textbox (named differently than your variable).

So with a text box named txtOrigDateExpired you can do:

Code:
Me.txtOrigDateExpired = OrigDateExpired

as long as OrigDateExpired is a variable with the correct scope (can be seen by the form - which means it should be either in the form's module, or a standard module and declared as Public (in the standard module it will be available throughout the whole program and in the form's module, just within that form).
 
Genious It works !

Thank you for your help and time,

Derek L
 

Users who are viewing this thread

Back
Top Bottom