Pre-poulate form fields with the previous entry

U

ukinusa

Hi everyone,
I am trying to pre-poulate the form fields with the previous entry.
am using the following code:
Private Sub Driver_AfterUpdate()
Driver.DefaultValue = "'" & Driver & "'"
End Sub

However, there is one field that needs to be incremented in it's value
It is a time field and it should be inceremented by 30 mins. How can
accomplish this?
Thanks,
Kira
 
U

ukinusa

I tried that but it's giving me an error. It just says =Name?. What am
doing wrong? Thanks
 
K

Klatuu

Did you change the name SomeTime to match the name on your form?
If that is not the case, you may have a missing library reference.
 
K

Klatuu

If it is a missiing reference, you might have trouble with other date
functions. You can check your references for any marked *missing*.

I doubt that is it. I think it is a naming problem. To ensure you do not
have a reference problem, do this in the immediate window:

x=now()
?x
You should see the current data and time
z = DateAdd("n",30,x)
?z
z should now be 30 minutes ahead of x.
If the line z = DateAdd("n",30,x) does not create an error, then it is a
naming problem rathter than a reference problem. Check all your names to be
sure there are no misspellings.
 
U

ukinusa

sorry, i didn't have a chance to work on it till today. I tried it an
what happens is that it increments the time the first time I clic
next, but not on the next ones.
Private Sub Timer_AfterUpdate()
Dim Test As Date
Test = DateAdd("n", 30, Timer)
Timer.DefaultValue = "'" & Test & "'"
End Sub

Say I entered the first record as 9:00 am, after I click next, it make
it 9:30 am, but from then on, it keeps it at 9:30 and doesn't incremen
the time. What can I do? Thanks
 
R

RoyVidar

ukinusa wrote in message
sorry, i didn't have a chance to work on it till today. I tried it and
what happens is that it increments the time the first time I click
next, but not on the next ones.
Private Sub Timer_AfterUpdate()
Dim Test As Date
Test = DateAdd("n", 30, Timer)
Timer.DefaultValue = "'" & Test & "'"
End Sub

Say I entered the first record as 9:00 am, after I click next, it makes
it 9:30 am, but from then on, it keeps it at 9:30 and doesn't increment
the time. What can I do? Thanks.

Could you try

Timer.DefaultValue = "#" & Test & "#"

and see if that changes anything?

But please also rename the name of your control, as timer is among
reserved words.
 
K

Klatuu

You are using a reserved word (Timer) that is causing this problem:
Test = DateAdd("n", 30, Timer)
Look in VBA Help to see info on the Timer function.
Try changing the name. Change the name Timer to something else and see what
happens.
 
J

John Vinson

sorry, i didn't have a chance to work on it till today. I tried it and
what happens is that it increments the time the first time I click
next, but not on the next ones.
Private Sub Timer_AfterUpdate()
Dim Test As Date
Test = DateAdd("n", 30, Timer)
Timer.DefaultValue = "'" & Test & "'"
End Sub

Say I entered the first record as 9:00 am, after I click next, it makes
it 9:30 am, but from then on, it keeps it at 9:30 and doesn't increment
the time. What can I do? Thanks.

The textbox's AfterUpdate event fires only when you type something
into the textbox - so if you're just accepting the default value it
never fires at all.

Try using the Form's AfterUpdate event instead, if you want the value
of Timer to increment by 30 seconds every time you add a new record.

John W. Vinson[MVP]
 
Top