MS Access Form Textbox

I have two textboxes on a form in continuous forms.  Starttime and Endtime.  I need to make my Starttime on the second line to be the same as the Endtime on the first line.  How can I do this?
deer777Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
You could use the AfterUpdate of the EndTime field to set the Default value of the StartTime field, but I would only do this when the record you are editing the EndTime on is a newrecord

Private Sub txt_EndTime_AfterUpdate

    if me.newrecord then
        me.txt_StartTime.DefaultValue = me.txt_EndTime
   Else
        me.txt_StartTime.DefaultValue = NULL
   End If

End Sub

Open in new window

0
deer777Author Commented:
I get a #Name? error in the StartTime field of the second record???
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Obviously you'd have to make sure you're using the right Control names and such. Dale's code would only work if you have controls named "txt_StartTime" and "txt_EndTime"
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

deer777Author Commented:
Yes I updated the controls accordingly.  I must be missing something because it updates automatically but only displays "#Name?" instead of the value
0
Dale FyeOwner, Developing Solutions LLCCommented:
another alternative would be to use the Form_BeforeUpdate event to capture the value in your [EndTime] column (or control).  To do this, you would have to declare a form level variable.
Private dtEndTime as date

Open in new window


Then use code similar to:
Private Sub Form_BeforeUpdate

    if me.NewRecord then
        dtEndTime = me.txt_EndTime
    else
        dtEndTime = NULL
    endif

End Sub

Open in new window

Then use the Form_Current event to check for a new record and if so, set the Value of [StartTime]
Private Sub Form_Current()

    if me.NewRecord then me.txt_StartTime = dtEndTime

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deer777Author Commented:
Worked perfect!  Thanks Dale!!
0
Dale FyeOwner, Developing Solutions LLCCommented:
glad I could help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.