Solved

Microsoft Access Continuous Form Question - Unbound Fields

Posted on 2011-09-07
14
271 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

743 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

13 Experts available now in Live!

Get 1:1 Help Now