Find a record problem

L

Lilian

Hi,
I did my own find a record in the form. Get some problem it shows the
records I want to find but doesn't show the marks I did in the multiselect
listboxes I did it by myself because I use Access 2003 file format. Do
someone knows how to fix this? When I use created by Access "find" it shows
all marked alternatives in the multiselect listbox. Here is the code to find
a record:

Option Compare Database
Option Explicit

Dim strSql As String, strSql1 As String
Dim strFiltr As String
Private Sub fldFiltr_AfterUpdate()

On Error GoTo Err_
If IsNull(Me.fldFiltr) Then
Me.Form.RecordSource = strSql & strSql1
strFiltr = ""
Text27 = "No Filter Form..."
Else
If Val(Me.fldFiltr.Column(1)) = 0 Then
If strFiltr = "" Then
strFiltr = Me.fldFind & "='" & Me.fldFiltr.Column(1) & "'"
Else
strFiltr = strFiltr & " or " & vbCrLf & Me.fldFind & "='" &
Me.fldFiltr.Column(1) & "'"
End If
Else
If strFiltr = "" Then
strFiltr = Me.fldFind & "=" & Me.fldFiltr.Column(1)
Else
strFiltr = strFiltr & " or " & vbCrLf & Me.fldFind & "=" &
Me.fldFiltr.Column(1)
End If
End If
Me.Form.RecordSource = strSql & " where " & strFiltr & strSql1
Text27 = "Filter Form: " & vbCrLf & strFiltr
End If
Exit_:
Exit Sub
Err_:
MsgBox Err.Description
Err.Clear
Resume Exit_
End Sub

Private Sub fldFind_AfterUpdate()

On Error GoTo Err_
If Not IsNull(Me.fldFind) Then
Me.fldFiltr.RowSource = "SELECT [ärende].ärendeid, [ärende]." &
Me.fldFind.Value & _
" FROM [ärende] " & _
"ORDER BY [ärende]." & Me.fldFind.Value
End If
Exit_:
Exit Sub
Err_:
MsgBox Err.Description
Err.Clear
Resume Exit_
End Sub

Private Sub Form_Open(Cancel As Integer)
strSql = "SELECT [ärende].* " & _
"FROM [ärende] "
strSql1 = " ORDER BY [ärende].ärendeid"
Me.Form.RecordSource = strSql & strSql1
strFiltr = ""
Text27 = "No Filter Form..."
End Sub
Best regards,
Lilian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top