Results 1 to 2 of 2
  1. #1
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72

    record selector code is not functional when a filter is applied

    Hi everyone,



    I am working on a record selector by using buttons which are developed by code. Here it is the database example ( http://www.mvp-access.com/-marta-/we...27&orden=&tipo= ). You can download the database in "Descargar Ejemplo". There are 3 buttons which are superimposed of each other.

    Also I have posted this before (https://www.accessforums.net/showthread.php?t=76441). But Unfortunately, for me it was a difficult code to use. Anyway, I want to thank again Isladogs for all the help

    The problem is that I have another code which work as a filter when certain fields are filled. But the record selector does not adjust to that filter. Instead of limiting to the number of records that have been searched, it does not.

    The filter has two buttons.


    -One for applying the search (Buscar Referencia). The purpose of this buttons is to look up by aproximation a certain reference or codigo RFQ. For example:

    Click image for larger version. 

Name:	a_filtrobusquedadatos_.PNG 
Views:	20 
Size:	6.0 KB 
ID:	38186

    Click image for larger version. 

Name:	a_filtrobusqueda_11.PNG 
Views:	20 
Size:	3.7 KB 
ID:	38187 My goal is to obtain something like this using the initial code.

    Click image for larger version. 

Name:	a_busqueda999.PNG 
Views:	20 
Size:	41.2 KB 
ID:	38192

    Code:
    Private Sub btn_BuscaReferencia_Click()
    
    Dim vBuscaReferencia As String
    Dim vBuscaCodigoRFQ As String
    
    Dim vLargo As Integer
    Dim miFiltro As String
    '--------------------------
    vBuscaReferencia = Nz(Me.cbo_BuscaReferencia.Value, "")
    vBuscaCodigoRFQ = Nz(Me.cbo_BuscaCodigoRFQ.Value, "")
    '--------------------------
    miFiltro = ""
    If vBuscaReferencia <> "" Then
    miFiltro = "AND [REFERENCIA] LIKE '*" & vBuscaReferencia & "*'"
    End If
    If vBuscaCodigoRFQ <> "" Then
    miFiltro = "AND [codigoRFQ] LIKE '*" & vBuscaCodigoRFQ & "*'"
    End If
    '--------------------------
    vLargo = Len(miFiltro)
    If vLargo > 0 Then
    miFiltro = Right(miFiltro, vLargo - 4)
    End If
    '------------------------
    
    If DCount("*", "aa_DatosRecibidos", miFiltro) = 0 Then      ' TABLE
    MsgBox "Los valores introducidos no se corresponden con ninguna REFERENCIA o CÓDIGO RFQ"    ' There are no references or codigo RFQ related to the initial values entered.
    Else
    Me.Filter = miFiltro
    Me.FilterOn = True
    End If
    End Sub
    And Undo search (Deshacer búsqueda):

    Code:
    Private Sub btn_DeshaceReferencia_Click()
    Me.cbo_BuscaReferencia.Value = Null
    Me.cbo_BuscaCodigoRFQ.Value = Null
    Me.FilterOn = False
    End Sub

    So, how do I implement the code which defines the record selector when the filter is applied and change according to the number of records filtered? What are the conditions I have to introduce?

    Thank you in advance

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    There were no buttons on the form for the dB "Descargar Ejemplo" form "BarraNavegacion".

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-26-2016, 11:20 AM
  2. Record Selector in Tabbed Forms
    By Michelle_Perron in forum Forms
    Replies: 6
    Last Post: 02-04-2014, 01:58 PM
  3. Replies: 4
    Last Post: 07-08-2012, 10:49 AM
  4. form record selector not working
    By jmk909er in forum Forms
    Replies: 3
    Last Post: 10-21-2010, 08:31 AM
  5. How to open a form with filter applied?
    By rkm360 in forum Access
    Replies: 1
    Last Post: 03-18-2009, 09:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums