RachelMiller-3447 avatar image
0 Votes"
RachelMiller-3447 asked

Form Behaves differently when loaded from search vs. opened directly

This is a stumper!

I have a set of forms designed to display search results. The forms are coded to sort by the column title when clicked and have some very basic "on open" code (I also tried adding this code to the "On Load" event, it made no impact):
Me.AllowAdditions = False
Me.AllowEdits = False
Me.AllowDeletions = False
Me.OrderBy = "LastName"
Me.OrderByOn = True

However, the only way a user can open any of these forms is through a search page that allows the user to choose all sorts of options.

At the end of the search function, I define the record source for the form:
SQL = "SELECT DISTINCTROW ParticipantContactandBackground., pAllProgramProcessProgress., pPlacementStatus.* FROM (ParticipantContactandBackground LEFT JOIN pAllProgramProcessProgress ON ParticipantContactandBackground.ParticipantID = pAllProgramProcessProgress.fkParticipantID) LEFT JOIN pPlacementStatus ON ParticipantContactandBackground.ParticipantID = pPlacementStatus.fkParticipantID WHERE " & Wh

DoCmd.OpenForm "PrimarySearchDemographics"
Forms!PrimarySearchDemographics.RecordSource = SQL

When the forms are opened from the search, the names are not sorted by last name and I cannot click on any of the column titles- nothing happens. As soon as I enter the VBA code for the page and switch back to form view, the sort function of the column titles works and the the form loads a list sorted by last name.

Any idea what the heck is happening here? I can't imagine why the form behaves so differently when I'm loading from the search function.

Happy to clarify further.
Thank you.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers