dbTalk Databases Forums  

Dfirst is not working correctly in Access 2007

comp.databases.ms-access comp.databases.ms-access


Discuss Dfirst is not working correctly in Access 2007 in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
JKRoyal
 
Posts: n/a

Default Dfirst is not working correctly in Access 2007 - 10-10-2011 , 10:46 AM






I am looking up the first record in a list that is sorted by date, but
it doesn't always return the next record in the list. Here is the
code:

Dim NextHearing As String
Dim NextDate As Variant
NextDate = DFirst("[Defendant] & ', on ' & [HearingDate] & ' at ' &
[HearingTime]", "qryHearings")

MsgBox "Your next hearing is for " & NextDate

Please tell me how to modify this so it always shows the next record
in the database sorted by date.
Thanks
John King
john (AT) sawtoothrecovery (DOT) com

Reply With Quote
  #2  
Old   
ron paii
 
Posts: n/a

Default Re: Dfirst is not working correctly in Access 2007 - 10-10-2011 , 12:16 PM






"JKRoyal" <john (AT) sawtoothrecovery (DOT) com> wrote

Quote:
I am looking up the first record in a list that is sorted by date, but
it doesn't always return the next record in the list. Here is the
code:

Dim NextHearing As String
Dim NextDate As Variant
NextDate = DFirst("[Defendant] & ', on ' & [HearingDate] & ' at ' &
[HearingTime]", "qryHearings")

MsgBox "Your next hearing is for " & NextDate

Please tell me how to modify this so it always shows the next record
in the database sorted by date.
Thanks
John King
john (AT) sawtoothrecovery (DOT) com
DFirst returns the 1st record it finds. Assuming qryHearings is sorted,
DFirst will return the same record as the 1st record displayed when you open
the query directly. If qryHearings is not sorted, DFirst will return
whatever happens to be the 1st record returned by the query. Not knowing
what you are trying to accomplished, you could open a record set on
qryHearing and use movefirst and movenext to scroll though the records in
your code.

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.