View Full Version : Apply Filter when Form Loads


MediaDoc
11-16-2002, 11:44 AM
Hi Everyone,

Have a form that is populated from 2 sources.

1. From client information table
2. From an email text string that is parsed for the appropriate fields (i.e. firstname, lastname etc).

The form displays any existing client information if its in the database on one side, and has the email text string contents on the other side.

I want the existing client info to display if the last name from the email text string is the same (i.e. filter the recordset when the form loads).

My filter (in the Form filter properties field is

((tblClientInformation.LastName=Forms!frmClientEnt ry.pLastName) AND (tblClientInformation.FirstName=Forms!frmClientEnt ry.pFirstName))

pFirstName / pLastName are from the parsed email text string.

This filter works when I do NOT have a Form_Load event procedure in code. (i.e. when I press the filter icon on the menu bar).

It does not work (nothing is displayed on the existing client information) side of the form when I call it using the Form_Load event procedure.

My code looks like:

Private Sub Form_Load()
Me.FilterOn = True
Me.Requery
End Sub

Any help appreciated!

Thanks,

Matts

chenn
12-03-2002, 09:13 AM
This won't work because the filter uses values from the form. On the load event, the text boxes on the form are not populated. Try using the on open event of the form and post what you get.