Need basic code on updating Time field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a contiuous form that has a date and time field in the records.
The date defaults to =Date, the time defaults to =Time.
This works great except that as soon as I put in the required fields for a
record, it automatically creates the next record with the current date & time.

What I'd like to do is be able to keep the form open and at some time in the
future, have some way to Update the time in a selected record to the current
time.

I've tried using the "double click" event on the field but it must default
to some standard edit command because it will just highlight the hour or
minutes to edit.

I've tried tieing a macro to the button but something just isn't right.
I'm pretty new to access so this should be pretty easy.

The Macro has "Set Value" action
The Item is [Time] which is the field name and name of the box on the form.
The expression is =Time()
Here is the Error message I get when pushing the macro button:
"The Expression Entered has Invalid Syntax"
"You may have entered an Operand without an Operator

Thanks for any help.
 
Open your form to design view, open properties and go to the Other tab.
Change the Cycle property to Current Record. That will take care of your
going to the next record.

Put a button beside your time textbox and out the following code in the
Click event:
Me!NameOfTimeTextBox = Time()
 
PC Datasheet,
I tried exactly what you proposed....
The error I get is that it can't find the macro "Me!Time= Time()"

I've also tried various changes in the macro "Update Time" and get the
Operand error I talked about before.

I've tried moving the button into the main part of the form and also in each
record detail and that doesn't seem to make a difference either.

BTW, I've seen the "Me!" type of string before but it doesn't make sense.
I can't find it mentioned anywhere in any help... Can you explain how that
command works?

Thanks again.



PC Datasheet said:
Open your form to design view, open properties and go to the Other tab.
Change the Cycle property to Current Record. That will take care of your
going to the next record.

Put a button beside your time textbox and out the following code in the
Click event:
Me!NameOfTimeTextBox = Time()

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Mike said:
I have a contiuous form that has a date and time field in the records.
The date defaults to =Date, the time defaults to =Time.
This works great except that as soon as I put in the required fields for a
record, it automatically creates the next record with the current date & time.

What I'd like to do is be able to keep the form open and at some time in the
future, have some way to Update the time in a selected record to the current
time.

I've tried using the "double click" event on the field but it must default
to some standard edit command because it will just highlight the hour or
minutes to edit.

I've tried tieing a macro to the button but something just isn't right.
I'm pretty new to access so this should be pretty easy.

The Macro has "Set Value" action
The Item is [Time] which is the field name and name of the box on the form.
The expression is =Time()
Here is the Error message I get when pushing the macro button:
"The Expression Entered has Invalid Syntax"
"You may have entered an Operand without an Operator

Thanks for any help.
 
Mike,

The button needs to be in your continuous form. Follow my instructions
again. When you open the Click event of the button, click on the three dots
at the right. In the dialog that appears, click on Code Builder and then
Click OK. You will be taken to the form's code window where you will see two
lines of code. Type Me!Time= Time() in=between those two lines then close
the code window and close your form. You will be asked whether you want to
save the changes, answer Yes.

"Me" is a shortcut representation of the reference to the form where you are
writing code. The long way to refer to a form is: Forms!MyForm. Me is
equivalent to Forms!MyForm.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Mike-z said:
PC Datasheet,
I tried exactly what you proposed....
The error I get is that it can't find the macro "Me!Time= Time()"

I've also tried various changes in the macro "Update Time" and get the
Operand error I talked about before.

I've tried moving the button into the main part of the form and also in each
record detail and that doesn't seem to make a difference either.

BTW, I've seen the "Me!" type of string before but it doesn't make sense.
I can't find it mentioned anywhere in any help... Can you explain how that
command works?

Thanks again.



PC Datasheet said:
Open your form to design view, open properties and go to the Other tab.
Change the Cycle property to Current Record. That will take care of your
going to the next record.

Put a button beside your time textbox and out the following code in the
Click event:
Me!NameOfTimeTextBox = Time()

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Mike said:
I have a contiuous form that has a date and time field in the records.
The date defaults to =Date, the time defaults to =Time.
This works great except that as soon as I put in the required fields for a
record, it automatically creates the next record with the current date
&
time.
What I'd like to do is be able to keep the form open and at some time
in
the
future, have some way to Update the time in a selected record to the current
time.

I've tried using the "double click" event on the field but it must default
to some standard edit command because it will just highlight the hour or
minutes to edit.

I've tried tieing a macro to the button but something just isn't right.
I'm pretty new to access so this should be pretty easy.

The Macro has "Set Value" action
The Item is [Time] which is the field name and name of the box on the form.
The expression is =Time()
Here is the Error message I get when pushing the macro button:
"The Expression Entered has Invalid Syntax"
"You may have entered an Operand without an Operator

Thanks for any help.
 
Back
Top