View Single Post
  #23  
Old April 8th, 2009, 05:58 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding
John S. Ford, MD
external usenet poster
 
Posts: 215
Default Form doesn't sort records per the underlying query

Dear Dirk,

I'm using Access 2000 and here's the code for the form's OnOpen event:

Private Sub Form_Open(Cancel As Integer)
If Me.Recordset.RecordCount = 0 Then
Cancel = True
MsgBox "No admissions meet these criteria.", vbExclamation
Else
strSearchCriteria = Me.OpenArgs
txtOpenArgs = strSearchCriteria
txtDCStatusCriteria = DLookup("DischargeStatusType",
"qryLIST_DischargeStatusTypes", "DischargeStatusTypeIDNum=" &
GetVarValFromArg(strSearchCriteria, "DCStatus"))
txtTeamCriteria = DLookup("TeamName", "qryLISTALL_Teams",
"TeamIDNum=" & GetVarValFromArg(strSearchCriteria, "Team"))
txtResidentCriteria = DLookup("ResidentName",
"qryLISTALL_Residents", "ResidentIDNum=" &
GetVarValFromArg(strSearchCriteria, "Resident"))
txtInternCriteria = DLookup("InternName", "qryLISTALL_Interns",
"InternIDNum=" & GetVarValFromArg(strSearchCriteria, "Intern"))
End If
End Sub

All of the stuff in the Else clause was commented out for the purpose of
this experiment so errors wouldn't be triggered without the OpenArgs
argument.

By the way, I REALLY appreciate the work you're doing on this, but believe
me, I'm not trying to get you to do this for me! Don't feel you have to
continue!!

John


"Dirk Goldgar" wrote in message
...
"John S. Ford, MD" wrote in message
...

I'm almost certain it's the strFinalWHERE that's doing it (and not
anything sitting in the OpenArgs argument) of the DoCmd.OpenForm
statement from the calling form.

DoCmd.OpenForm "frmAdmissionEntryForm", , , strFinalWHERE
gives me unsorted records (though filtered).

DoCmd.OpenForm "frmAdmissionEntryForm"
gives me SORTED records (though unfiltered).

Somewhere the WHERE argument is sabotaging my underlying query's ORDER BY
clause.



That is certainly suggestive, but I can't reproduce it, and I still want
to see the code in your form's Open and/or Load event. What version of
Access are you using?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)