?
Solved

Microsoft Access Continuous Form Question - Unbound Fields

Posted on 2011-09-07
14
Medium Priority
?
308 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 800 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
Dale Fye earned 400 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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 800 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
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

765 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