date function

S

SIN

hi,
how can i use in date function?

the field type is date :
Me.date = date <---- i get null
also in here:
MsgBox "DATE - '" & date & "' " <<<

thanks.
 
S

storrboy

That depends on where you are using it.
Is Me.date a control on your form? If so, that will cause problems
right off the bat. Date is a reserved word as it is the name of a
function. Naming ANYTHING in your project the same as such a reserved
word will cause problems. You should rename the control or field or
whatever that is.

Your usage of the Date function looks correct though.
 
S

SIN

thanks, I using in vb ,
i try to add () to the procedure but the program delete the brackets.
Private Sub CmdExecute_Click()
Me!date = date
MsgBox "DATE - '" & date () & "' " <<<
End Sub
 
F

FedBrad

Sorry, I did not assume that the actual field name was "date"... storrboy is
absolutely correct, and there are several 'reserved' words to avoid.
 
J

John W. Vinson

hi,
how can i use in date function?

the field type is date :
Me.date = date <---- i get null
also in here:
MsgBox "DATE - '" & date & "' " <<<

thanks.

Change the fieldname. Access is probably getting confused about whether you
mean the word "date" to refer to the fieldname Date, or the built-in function
Date().


John W. Vinson [MVP]
 
J

John W. Vinson

thanks, I using in vb ,
i try to add () to the procedure but the program delete the brackets.
Private Sub CmdExecute_Click()
Me!date = date
MsgBox "DATE - '" & date () & "' " <<<
End Sub

If there is a control named date - either rename it, or put it in brackets:

Me![date] = Date

Best to change both the control name and the fieldname though - Access *WILL*
(not may but will) get confused.

John W. Vinson [MVP]
 
S

SIN

it's not working;
I Change the fieldname: I get null when i update the filed and even in the
message

Me!Invoice_Date = date
sMyText = "Date " & date & ""
MsgBox sMyText
 
S

storrboy

Did you change all occurances of it, not just this form?
Did the control name change to match the fieldname?
Did you change the ControlSource of the control to point to the new
field name?

In the VB editor go to the Debug menu and click on Compile
[PorjectName]. See what other errors occur and fix those.
 
Top