Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / April 2008

Tip: Looking for answers? Try searching our database.

Check for a value in the results of a query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
magicdds- - 17 Apr 2008 19:48 GMT
I have a query with a number of resulting records. I need to check if PARTYID
in any of those records equals PARTYID in my subform.

I was going to put code in the AfterUpdate property of PARTYID on the
subform to check the list of records returned by the query. I know I can
check the first record with a DLookUp statement, but I don't know how to
scroll through all of the records returned by the query, to check the results.

Can anyone suggest how to do this.

Thanks,
Mark
George Nicholson - 17 Apr 2008 20:15 GMT
> I know I can check the first record with a DLookUp statement...

You are thinking of DFirst(). DLookup looks at all the records in the
table/query and returns a value *if* a matching record is found, so you
should be able to use it for what you want. (aircode follows)

lngResult = Nz(Dlookup("[PartyID]", "qrySomeQuery","[PartyID] = " &
Form!SubformControl!Form!PartyIDControl),0)
If lngResult = 0
   ' Dlookup didn't find a match, so it returned Null. We changed Null to
Zero to avoid a TypeMismatch error.
   MsgBox "No Matching Record"
Else
   Msgbox "Match found"
End If

Signature

HTH,
George

>I have a query with a number of resulting records. I need to check if
>PARTYID
[quoted text clipped - 10 lines]
> Thanks,
> Mark
magicdds- - 18 Apr 2008 02:05 GMT
With a little tweeking, I got it to work.
Thanks George

> > I know I can check the first record with a DLookUp statement...
>
[quoted text clipped - 26 lines]
> > Thanks,
> > Mark
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.