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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign code to a button

Status
Not open for further replies.

misulica

Programmer
Feb 8, 2003
43
RO
What code I must assign to a command button to add a new record into a "DATE" column, date give by the computer clock (I need only the month & year)
 
in command.click:

insert into tablename(date) values(date())

this code will insert into table "tablename" one record. Only field date=curentdate on your computer.

Sometmes I use this function to store only curent mounth and year:
in command.click:
_date=ctod(str(1)+month(date())+year(date()))
insert into tablename(date) values(_date)

Then rocords look like this:
tablename.date="1.02.2003"
tablename.date="1.03.2003"
tablename.date="1.04.2003"
 
I use your code, and I receive this message:
Operator/operand type mismatch

I press ignore nad then appeared:
Variable'_DATE' is not found.

What can I do?Thanks
 
misulica

What is the field definition of your DATE field? Is it a date type field? If it is then BON011's first suggestion should work for you:
Code:
insert into tablename(date) values(date())

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Yes, ofcourse it is.Maybe the error is given because I use for the clock the romanian date (day/month/year)?
 
misulica

Yes, ofcourse it is.Maybe the error is given because I use for the clock the romanian date (day/month/year)?

It should not make a difference, as many parts of the world uses that format. Try the following in a small program:
Code:
SET DATE DMY
CREATE cursor myCursor (DATE1 D)
INSERT INTO myCursor (DATE1) VALUES (DATE())
BROWSE

Do you get a date inserted into the cursor? Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
misulica

Then if your field in your table is a date field, then the same code should work on your table. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top