Solved

Microsoft Access Continuous Form Question - Unbound Fields

Posted on 2011-09-07
14
277 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
  • 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 119

Expert Comment

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

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
 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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 47

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 119

Expert Comment

by:Rey Obrero
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now