View Full Version : Form Filtering


ianacole
12-03-2001, 02:43 PM
I have two forms. One for Customer information, including a subform for activity history. The second form is to allow AE's to filter the record set by RecordNumber, CustomerName, or AEName. Here is the code I have so far...

Private Sub RtrvFormCmnd_Click()
On Error GoTo Err_RtrvFormCmnd_Click

Dim stDocName As String
Dim stOpenForm As String
Dim stLinkCriteria As String
Dim stLinkCriteriaRN As Integer
Dim intRecordNum As Integer

stDocName = "Lead Management"
stOpenForm = "FormLookup"

If Not IsNull(Combo15) Then
stLinkCriteriaRN = "[Record Number]=" & "'" & Me![Combo15] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stOpenForm, acSaveNo
Exit Sub
End If

If Not IsNull(Combo13) Then
stLinkCriteria = "[Company Name]=" & "'" & Me![Combo13] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stOpenForm, acSaveNo
Exit Sub
End If

If Not IsNull(Combo10) Then
stLinkCriteria = "[Adelphia Contact]=" & "'" & Me![Combo10] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, stOpenForm, acSaveNo
Exit Sub
End If

' If Not IsNull(Text17) Then
' stLinkCriteria = Like "*" & "[Company Name]=" & "'" & Me![Combo10] & "'" "*"
' DoCmd.OpenForm stDocName, , , stLinkCriteria
' DoCmd.Close acForm, stOpenForm, acSaveNo
' Exit Sub
' End If

Exit_RtrvFormCmnd_Click:
Exit Sub

Err_RtrvFormCmnd_Click:
MsgBox Err.Description
Resume Exit_RtrvFormCmnd_Click



End Sub


How can I do this better. From what I have done, I have to have a second table housing the RecordNumber, CustomerName, and AEName that mirrors the original table (LeadManagement). If I don't set it up like this, I get "can't open LeadManagement Form because it is opened exclusively by another user/query (which is the drop lists on FilterForm).

Lastly, I would like to be able to have a field that they could enter a portion of a company name (i.e. "Micro") and have all Record Sets returned that meet that that word (i.e. Microsoft, Microcenter, etc.)

Any ideas?

Thanks,

Ian