Modified Allenbrowne Search Form displays error

  • Thread starter Thread starter sebastico
  • Start date Start date
S

sebastico

Hello

I have been trying to get a Form to search in a Access 2003 db based in
allenbrowne SearchForm. The fields are one table:
ObraID(String)
Año(String)
AutNomb(String)
Titulo(String)
Resumen(Memo)

Nevertheless, on clicking the "filter" the db displays in
(Me.txtFilterResumen) : "Compile
error:Method or data member not found".

Due to this error, I don't know if all code is correct and I need to run it.
Could you help
me to fix this error?

My code is:

Option Compare Database
Option Explicit

Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.txtFilterObraID) Then
strWhere = strWhere & "([ObraID] = """ & Me.txtFilterObraID & """) AND "
End If


If Not IsNull(Me.txtFilterAño) Then
strWhere = strWhere & "([Año] = """ & Me.txtFilterAño & """) AND "
End If


If Not IsNull(Me.txtFilterAutNomb) Then
strWhere = strWhere & "([AutNomb] Like ""*" & Me.txtFilterAutNomb & """)
AND "
End If


If Not IsNull(Me.txtFilterTitulo) Then
strWhere = strWhere & "([Titulo] Like """ & Me.txtFilterTitulo & """)
AND "
End If


If Not IsNull(Me.txtFilterResumen) Then
strWhere = strWhere & "([Resumen] = """ & Me.txtFilterResumen & """) AND "
End If

lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "Sin criterio", vbInformation, "Nada que hacer."
Else
strWhere = Left$(strWhere, lngLen)

(Ctrl+G).
'Debug.Print strWhere

Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub

Private Sub cmdReset_Click()

Dim ctl As Control

For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next

Me.FilterOn = False
End Sub

Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = True
MsgBox "Usted no puede agregar nuevos autores al formulario de
búsqueda.", vbInformation, "Permiso denegado."
End Sub

Private Sub Form_Open(Cancel As Integer)
'Me.Filter = "(False)"
'Me.FilterOn = True
End Sub

Many thanks
 
Many thanks Bruce.
Following your message I fixed the error.

BruceM via AccessMonster.com said:
Click Debug >> Compile on the vBA editor menu. Is a line of code highlighted?


If the code compiles correctly, set a break point by opening the code in the
VBA editor, then clicking on the vertical bar to the left of the code (next
to the first If Not IsNull would be a good place. This should cause a dot to
appear on the vertical bar, and the line of code to be highlighted. Go to
Form view of the form and click the command button. The code will stop at a
problem line.

Tow things I see is that you are treating AutoNomb as text, when perhaps it
is a number. In fact, you are treating all fields as text. If they are not,
that could cause problems.

Hello

I have been trying to get a Form to search in a Access 2003 db based in
allenbrowne SearchForm. The fields are one table:
ObraID(String)
Año(String)
AutNomb(String)
Titulo(String)
Resumen(Memo)

Nevertheless, on clicking the "filter" the db displays in
(Me.txtFilterResumen) : "Compile
error:Method or data member not found".

Due to this error, I don't know if all code is correct and I need to run it.
Could you help
me to fix this error?

My code is:

Option Compare Database
Option Explicit

Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.txtFilterObraID) Then
strWhere = strWhere & "([ObraID] = """ & Me.txtFilterObraID & """) AND "
End If

If Not IsNull(Me.txtFilterAño) Then
strWhere = strWhere & "([Año] = """ & Me.txtFilterAño & """) AND "
End If

If Not IsNull(Me.txtFilterAutNomb) Then
strWhere = strWhere & "([AutNomb] Like ""*" & Me.txtFilterAutNomb & """)
AND "
End If

If Not IsNull(Me.txtFilterTitulo) Then
strWhere = strWhere & "([Titulo] Like """ & Me.txtFilterTitulo & """)
AND "
End If

If Not IsNull(Me.txtFilterResumen) Then
strWhere = strWhere & "([Resumen] = """ & Me.txtFilterResumen & """) AND "
End If

lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "Sin criterio", vbInformation, "Nada que hacer."
Else
strWhere = Left$(strWhere, lngLen)

(Ctrl+G).
'Debug.Print strWhere

Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub

Private Sub cmdReset_Click()

Dim ctl As Control

For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next

Me.FilterOn = False
End Sub

Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = True
MsgBox "Usted no puede agregar nuevos autores al formulario de
búsqueda.", vbInformation, "Permiso denegado."
End Sub

Private Sub Form_Open(Cancel As Integer)
'Me.Filter = "(False)"
'Me.FilterOn = True
End Sub

Many thanks

--
Message posted via AccessMonster.com


.
 
Back
Top