Microsoft Access Continuous Form Question - Unbound Fields

Hello everyone,

My application uses a continuous form named "frmSVR" which is based upon a query.  The query includes all records from the SVR table that have a status of Active.  As a result, when I open the form I see 10 continous forms.

One of the fields displays the date and time that the SVR was requested.  I would like to add a second field which calculates how many minutes it has been since the SVR was requested.

I created an UNBOUND field called HobbsTime and added the following code to the ON_Current event procedure.

Me.HobbsTime = DateDiff("n", Me.RequestDate, Now)

I was hoping this would calculate the number of minutes since the SVR was created and display such on each form, however, every form is display with the same calculation.


RequestedTime                     HobbsTime
9/3/2011 3:05PM                           23
9/3/2011 4:30PM                           23
9/5/2011 2:22PM                           23

I suspect I need to change the name of the HobbsTime field in each form but don't know how.
Please help!

Who is Participating?
raremindConnect With a Mentor Commented:
Add the code to the control; source of the unbound textbox and not in an event

open the form in design view
in the control source on the unbound box add:
= DateDiff("n", Me.RequestDate, Now)

Give it a try
Rey Obrero (Capricorn1)Commented:
that is a NORMAL behavior of an UNBOUND control in a continuous form
Dale FyeConnect With a Mentor Commented:
Agree with Capricorn1.  Your best bet is to include the DateDiff() function call in the query that is the source of the form.  The down side is that this will make that value as of the time the form was last opened, refreshed, or requeried.

You could put some code in the current event or some other event on the form to refresh or requery the form, which would update that value.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Rey Obrero (Capricorn1)Commented:
create an additional column
  HobbsTime : DateDiff("n", Me.RequestDate, Now)

to your query and make it the Control Source of the Unbound control
mbizupConnect With a Mentor Commented:
<that is a NORMAL behavior of an UNBOUND control in a continuous form>

Refining that... it is normal behavior of unbound controls - it is just most apparent in a continuous form.

"Me" is a prefix used in VBA.

Either using the control source property (first comment) or using an extra field in the query will work, but you need to leave off the "Me." and just refer to the field.


Control source (include the = sign):
= DateDiff("n", [RequestedTime], Now)

or field in query:

DateDiff("n", [RequestedTime], Now)

Double -check your field name.  You are referrring to both RequestedTime  and RequestDate in your original post.

Rey Obrero (Capricorn1)Commented:

create an additional column
  HobbsTime : DateDiff("n", [RequestDate], Now)

to your query and make it the Control Source of the Unbound control

@mbizup Thanks forgot to remove the second me. :)
pcalabriaAuthor Commented:
Thanks everyone, problem solved!

I'm not sure how to award the point on this one, as I don't use this site often enough to know how others in the community award points.  I hurt someone's feelings once before when I split points, so I'd like some opinions on the right thing to do this time is.

I loved rareminds solution, but as we know, the approach was sound although the syntax was, in effect, wrong.  The "me" portion of the code caused the code to fail, and I was left with a #name in the field.

I realized that Caps solution could have worked also, however, it seemed simpler to modify the Control Source in the form...

mbizup provided the code that I ultimately used, which was the code offered by rareminds with the "me." removed.

fyed suggested code in the an event to refresh the form, and I decided to do so using the onTimer event.

Dale FyeCommented:
You don't generally need to worry about hurting someones feelings, unless they were the first one to post a solution and you awarded all the points to someone else with the exact same solution.  Even then, most of us just shake it off.  

We are not here (at least most of us) for the points; we are here to help.
What I do is give the points to the solution that worked and solved the problem easiest and keep in mind most techs don't mind being snubbed LOL. I don't even flinch anymore when someone gets the points when I proposed the same solution three posts ahead of them.
Rey Obrero (Capricorn1)Commented:
<I loved rareminds solution>

I think that says a lot right there.  If that's what you used, it should get the lion's share of the points.  My own post was a minor correction.  You have the option of splitting points for 'assisted' answers too.

aaaaaannnnnnddddd........ you do realize you opened yourself up to every person on this post going a little ballistic when you do give the posts LOL :)
pcalabriaAuthor Commented:
Okay... thanks for all of your help and suggestions on distributing the points.

The code is working and now I have a much better perspective on how this website works.

Thanks again.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.