Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 21st, 2005, 10:43 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Automatically select value from a calculated field

Hello to everyone...

I have a calculated(unbound) text field named(Age) on my main form. The Age is calculated based on patient's DOB(Date of Birth) Field using datediff function, and in the subform, I have a field named (AgeNo).

There is a criteria for AgeNo Field depending on (Age) field for each patient.

Criteria:

If Age is 18-40 = AgeNo should be 0
If Age is 41-60 = AgeNo should be 1
If Age is 61-70 = AgeNo should be 2
If Age is >71 = AgeNo should be 3

MRN (Med. Rec. No) field & Age are in Main form and AgeNo field is in a subform.
I want the AgeNo field to automatically select ( 0, 1, 2 or 3 ) based on the calculated unbound text field(Age) but for some reason, the Dlookup function can't capture the Age(unboound field). Is there another way of doing this? Thanks...

here's the code:
Private Sub Form_Current()
Dim bytAge As Byte

bytAge = Nz(DLookup("[Age]", "tblPatient_Demographics", "[MRN] = '" & Me.MRN & "'"), 0)

Select Case bytAge
Case 18 To 40
Me.AgeNo = 0
Case 41 To 60
Me.AgeNo = 1
Case 61 To 70
Me.AgeNo = 2
Case 71 To 150
Me.AgeNo = 3
End Select
End Sub


Many thanks...:)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouping with calculated field in report jack123 Access 3 August 9th, 2007 06:46 AM
Form's calculated field not working properly PaulJH Access 11 March 5th, 2007 09:52 AM
How to create a Calculated Field fdtoo SQL Server 2000 0 April 11th, 2006 08:34 PM
Auto Calculated Field in Access anubhav.kumar Access 1 March 15th, 2005 08:37 AM
Validate calculated field in sub form MG76 Access 4 March 18th, 2004 04:26 PM



All times are GMT -4. The time now is 01:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.