Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetValue to Now() in Macro 1

Status
Not open for further replies.

firsttube

Technical User
Apr 21, 2004
165
CA
I have a button that has an onclick macro that is supposed to put the current date into the field.

I have:

Action: SetValue
Item: [DATE_APPROVED]
Expression: =Now()

But I get an error when I click the button. How can this be fixed?

thanks

ft
 
First step is to abanden MACROs and use VB code



Then use:-

Private Sub cmdButton_OnClick()
textBoxName = Now()
End Sub



'ope-that-elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
firsttube

So the end user clicks on the "Approval" button, and the current date is assigned approved date?

Have you considered using an event procedure instead?

In the properties field for the command button, select the "Event" window, select "On Click", select [Event Procedure] from the list, and then select the "..." icon to the right.

Code would be...
Code:
Me.YourApprovalDateField = DATE()

(DATE command is returns the system date, NOW returns date + time)




 
I would use VB for this except I have a lot of other actions in the macro that occur onclick, and I don't really want to convert it to VB (although that might be the answer in this case). And I do want date and time.

Should I convert to VB, or can this be done in the macro?
 
But I get an error when I click the button.
Any chance you could post some interesting infos like, say, the error message ... ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
sorry...

here's the error message:

"The expression you entered contains invalid syntax. You may have entered an operand without an operator."

thanks

ft

Set the gearshift for the high gear of your soul, you've got to run like an antelope, out of control.
 
firsttube

Then you need to look at your macro and post it for review.

MyDateField NOW()
would generate an error

MyDateField = NOW()
would address the problem.

Likewise...

MyCalc = CALC1 CALC2
error

MyCalc = CALC1 + CALC2
or - / *

+ - / *
are types of operands

But the error can be confusing, because you may want to join strings together...

Have...
MyString = String1 String2
Need...
MyString = String1 & String2

Richard
 
my macro is:

Action: SetValue
Item: [DATE_APPROVED]
Expression: =Now()


thanks

ft

Set the gearshift for the high gear of your soul, you've got to run like an antelope, out of control.
 
change it to...

Action: SetValue
Item: [DATE_APPROVED]
Expression: Now()

take out the equals sign...
 
Thanks alot for that help! I should have known!!!

ft

Set the gearshift for the high gear of your soul, you've got to run like an antelope, out of control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top