PC Review


Reply
Thread Tools Rate Thread

Cycle through records to find a value

 
 
Rob M
Guest
Posts: n/a
 
      26th Aug 2011
Hi everyone,

I'm wondering whether someone can help with this.

I have a patient database that handles referrals from multiple
clinics. On main patient form, that contains a Referrals subform, I'm
trying to flag whether a referral to a specific clinic has been made.
The VBA code I have so far looks something like this:

--
Dim PatientIDTemp as integer
Dim ClinicFlag as boolean

PatientIDTemp = Me![PatientID]

NumberOfReferrals = DCount("[ClinicID]", "Referrals", "[PatientID] = "
& PatientIDTemp)

For b = 1 To NumberOfReferrals
(now I want to cycle through all the referrals for that patient, and
simply flag if the ClinicID = 8 (e.g., ClinicFlag = True)
Next b
--

It's easy enough to flag when there's only one referral (e.g., If
Referrals![ClinicID] = X Then ClinicFlag = True). The problem is that
I'm not sure how to cycle through all of the referrals to find the
particular one in question. Can anyone assist with coding this? I
may be way off base with what I have so far. I'd be really grateful
for any help.

Many thanks,
Rob
 
Reply With Quote
 
 
 
 
Access Developer
Guest
Posts: n/a
 
      26th Aug 2011
Why don't you include the Clinic in the Link Master Fields and Link Child
Fields of the Subform Control, and save yourself a lot of trouble... or, if
you want to show all referrals, but with particular ones checked, you can
use a Calculated Field to return the Boolean value that would set a Check
Box,

--
Larry Linson, Microsoft Office Access MVP
Co-author: "Microsoft Access Small Business Solutions", published by Wiley
Access newsgroup support is alive and well in USENET
comp.databases.ms-access



"Rob M" <(E-Mail Removed)> wrote in message
news:a9440cff-a63f-4c6d-8a59-(E-Mail Removed)...
> Hi everyone,
>
> I'm wondering whether someone can help with this.
>
> I have a patient database that handles referrals from multiple
> clinics. On main patient form, that contains a Referrals subform, I'm
> trying to flag whether a referral to a specific clinic has been made.
> The VBA code I have so far looks something like this:
>
> --
> Dim PatientIDTemp as integer
> Dim ClinicFlag as boolean
>
> PatientIDTemp = Me![PatientID]
>
> NumberOfReferrals = DCount("[ClinicID]", "Referrals", "[PatientID] = "
> & PatientIDTemp)
>
> For b = 1 To NumberOfReferrals
> (now I want to cycle through all the referrals for that patient, and
> simply flag if the ClinicID = 8 (e.g., ClinicFlag = True)
> Next b
> --
>
> It's easy enough to flag when there's only one referral (e.g., If
> Referrals![ClinicID] = X Then ClinicFlag = True). The problem is that
> I'm not sure how to cycle through all of the referrals to find the
> particular one in question. Can anyone assist with coding this? I
> may be way off base with what I have so far. I'd be really grateful
> for any help.
>
> Many thanks,
> Rob



 
Reply With Quote
 
Bob Quintal
Guest
Posts: n/a
 
      26th Aug 2011
Rob M <(E-Mail Removed)> wrote in
news:a9440cff-a63f-4c6d-8a59-(E-Mail Removed)
m:

> Hi everyone,
>
> I'm wondering whether someone can help with this.
>
> I have a patient database that handles referrals from multiple
> clinics. On main patient form, that contains a Referrals subform,
> I'm trying to flag whether a referral to a specific clinic has
> been made. The VBA code I have so far looks something like this:
>
> --
> Dim PatientIDTemp as integer
> Dim ClinicFlag as boolean
>
> PatientIDTemp = Me![PatientID]
>
> NumberOfReferrals = DCount("[ClinicID]", "Referrals", "[PatientID]
> = " & PatientIDTemp)
>
> For b = 1 To NumberOfReferrals
> (now I want to cycle through all the referrals for that
> patient, and
> simply flag if the ClinicID = 8 (e.g., ClinicFlag = True)
> Next b
> --
>
> It's easy enough to flag when there's only one referral (e.g., If
> Referrals![ClinicID] = X Then ClinicFlag = True). The problem is
> that I'm not sure how to cycle through all of the referrals to
> find the particular one in question. Can anyone assist with
> coding this? I may be way off base with what I have so far. I'd
> be really grateful for any help.
>
> Many thanks,
> Rob


why not expand the dLookup to count your ClinicID so that if it's
there your answer is 1, else it's 0

NumberOfReferrals = DCount("[ClinicID]", "Referrals", _
"[PatientID] = "& PatientIDTemp _
& " AND [ClinicID] = " & X & ")"


--
Bob Q.
PA is y I've altered my address.
 
Reply With Quote
 
Rob M
Guest
Posts: n/a
 
      27th Aug 2011
Thank you Bob Q, this suggestion worked perfectly!! I really
appreciate your help.



> why not expand the dLookup to count your ClinicID so that if it's
> there your answer is 1, else it's 0
>
> NumberOfReferrals = DCount("[ClinicID]", "Referrals", _
> "[PatientID] = "& PatientIDTemp _
> & " AND [ClinicID] = " & X & ")"
>
>
> --
> Bob Q.
> PA is y I've altered my address.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cycle Through records WireGuy Microsoft Access Form Coding 0 7th Feb 2009 04:35 AM
Cycle of records Edan Mimran via AccessMonster.com Microsoft Access Form Coding 6 6th Sep 2005 03:32 AM
Cycle Records =?Utf-8?B?S2FyZW4=?= Microsoft Access Forms 3 18th Aug 2005 03:27 AM
cycle records in a form Martin Microsoft Access Form Coding 1 27th Feb 2004 01:55 AM
key down to cycle records David Microsoft Access Forms 1 28th Dec 2003 11:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:19 AM.