Solved

Microsoft Access Continuous Form Question - Unbound Fields

Posted on 2011-09-07
14
304 Views
Last Modified: 2012-05-12
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.

Example:

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!

0
Comment
Question by:pcalabria
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +2
14 Comments
 
LVL 4

Accepted Solution

by:
raremind earned 200 total points
ID: 36496285
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
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36496290
that is a NORMAL behavior of an UNBOUND control in a continuous form
0
 
LVL 48

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 100 total points
ID: 36496366
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 120

Expert Comment

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

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

Assisted Solution

by:mbizup
mbizup earned 200 total points
ID: 36496780
<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.

ie:

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.




 
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36496804
correction


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

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




0
 
LVL 4

Expert Comment

by:raremind
ID: 36496821
@mbizup Thanks forgot to remove the second me. :)
0
 

Author Comment

by:pcalabria
ID: 36497500
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.

0
 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 36497547
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.
0
 
LVL 4

Expert Comment

by:raremind
ID: 36497698
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.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36497786
ditto...
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36497902
<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.

0
 
LVL 4

Expert Comment

by:raremind
ID: 36498432
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 :)
0
 

Author Closing Comment

by:pcalabria
ID: 36500331
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.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question