DreamPearl Posted May 6, 2009 at 09:11 AM Report #261799 Posted May 6, 2009 at 09:11 AM Olá a todos! Por favor alguem me pode ajudar ..... :bye2: Estou a trabalhar numa bd em access 2000 e preciso de fazer pesquisa multipla por varias combos... O cliente "x" k esta na area "y" cujo processo esta "Aberto".... Preciso disso com urgencia, tou estagiando... se puderem nem k seja mandar exemplos..... Obrigada
jpaulino Posted May 6, 2009 at 09:13 AM Report #261800 Posted May 6, 2009 at 09:13 AM Tens de dar mais detalhes do que como queres fazer e do que já tens feito.
DreamPearl Posted May 6, 2009 at 09:17 AM Author Report #261801 Posted May 6, 2009 at 09:17 AM Olá Bom dia! Tenho assim: ‘PESQUISA POR AREA DE NEGOCIO(uma combobox(“área”) que carrega as areas a partir da tabela Área de negocio): Private Sub area_Change() Dim s As String Forms![mapa de processos].RecordSource = "mapa2" s = "SELECT NºProcesso, UltimaVersao, Nome, Contacto, AreaNegocio, Situação_processo, [Data Entrega_Montagem], Prazo_limite_ent_mont, [Estado Entrega_montagem], AssuntoNOficial FROM mapa2 WHERE AreaNegocio LIKE '" & Me!area.Value & "'" Me.RecordSource = s 'Me.Refresh End Sub ‘ UMA COMBO E UMA CAIXA DE TEXTO, DENTRO DA COMBO(campo) TEMOS NOME DE CLIENTE, CONTACTO E ASSUNTO NÃO OFICIAL: Private Sub campo_Change() End Sub Private Sub Comando54_Click() Dim sql As String Dim criterio As String Forms![mapa de processos].RecordSource = "mapa2" criterio = campo.Value Select Case campo Case "Nome de cliente" sql = "SELECT Processo_n, UltimaVersao, Nome, Contacto, AreaNegocio, Situação_processo, [Data Entrega_Montagem], Prazo_limite_ent_mont, [Estado Entrega_montagem], AssuntoNOficial FROM mapa2 WHERE Nome LIKE '%" & Me!TextoPesq.Value & "%'" Me.RecordSource = sql 'Me.Refresh Case "Contacto" sql = "SELECT Processo_n, UltimaVersao, Nome, Contacto, AreaNegocio, Situação_processo, [Data Entrega_Montagem], Prazo_limite_ent_mont, [Estado Entrega_montagem], AssuntoNOficial FROM mapa2 WHERE Contacto LIKE '%" & Me!TextoPesq.Value & "%'" Me.RecordSource = sql 'Me.Refresh Case "Assunto não oficial" sql = "SELECT Processo_n, UltimaVersao, Nome, Contacto, AreaNegocio, Situação_processo, [Data Entrega_Montagem], Prazo_limite_ent_mont, [Estado Entrega_montagem], AssuntoNOficial FROM mapa2 WHERE AssuntoNOficial LIKE '%" & Me!TextoPesq.Value & "%'" Me.RecordSource = sql 'Me.Refresh End Select End Sub 'FILTRO POR ESTADO DE ENTREGA/MONTAGEM (COMBOBOX): Private Sub entrega_montagem_Change() Dim x As String Forms![mapa de processos].RecordSource = "mapa2" x = "SELECT Processo_n, UltimaVersao, Nome, Contacto, AreaNegocio, Situação_processo, [Data Entrega_Montagem], Prazo_limite_ent_mont, [Estado Entrega_montagem], AssuntoNOficial FROM mapa2 WHERE [Estado Entrega_montagem] LIKE '" & Me!entrega_montagem.Value & "'" Me.RecordSource = x 'Me.Refresh End Sub 'FILTRO POR SITUAÇÃO DO PROCESSO Private Sub situacao_Change() Dim exp As String Forms![mapa de processos].RecordSource = "mapa2" exp = "SELECT Processo_n, UltimaVersao, Nome, Contacto, AreaNegocio, Situação_processo, [Data Entrega_Montagem], Prazo_limite_ent_mont, [Estado Entrega_montagem], AssuntoNOficial FROM mapa2 WHERE Situação_processo LIKE '" & Me!situacao.Value & "'" Me.RecordSource = exp 'Me.Refresh End Sub ' MOSTRAR TODOS OS REGISTOS E LIMPAR FILTROS Private Sub tudo_Click() Dim sql As String Forms![mapa de processos].RecordSource = "mapa2" TextoPesq = "" campo = "" situacao = "" entrega_montagem = "" area = "" sql = "SELECT Processo_n, UltimaVersao, Nome, Contacto, AreaNegocio, Situação_processo, [Data Entrega_Montagem], Prazo_limite_ent_mont, [Estado Entrega_montagem], AssuntoNOficial FROM mapa2" Me.RecordSource = sql Me.Refresh End Sub E agora preciso de uma string para juntar todos esses filtros num... Axo eu... ? Obrigada...
DreamPearl Posted May 6, 2009 at 02:06 PM Author Report #261858 Posted May 6, 2009 at 02:06 PM e então?? Alguem tem alguma ideia?? :dontgetit: :(Por favor!!! Tou mesmo precisando.... 😞
DreamPearl Posted May 6, 2009 at 03:07 PM Author Report #261869 Posted May 6, 2009 at 03:07 PM Olhem atraves dum exemplo k encontrei na Net : Function fGetWhere() as String Dim strWhere as String If nz(Len(Me.area),0)>0 Then strWhere = "AreaNegocio = " & Me.area.value End If If nz(Len(Me.entrega_montagem),0)>0 Then strWhere = fGetAnd(strWhere) & "[Estado Entrega_montagem] = " & Me. entrega_montagem.value End If If nz(Len(Me.situacao),0)>0 Then strWhere = fGetAnd(strWhere) & "[situação_processo] = " & Me. situacao.value End If If nz(Len(Me.campo),0)>0 Then Select case campo Case “Nome de cliente” strWhere = fGetAnd(strWhere) & "Nome = " & Me.TextoPesq.value Case “Contacto” strWhere = fGetAnd(strWhere) & "Contacto = " & Me.TextoPesq.value Case “Assunto não oficial” strWhere = fGetAnd(strWhere) & " AssuntoNOficial = " & Me.TextoPesq.value End If 'wash, rinse, repeat for each control If Nz(Len(strWhere),0)>0 Then fGetWhere = "WHERE " & strWhere End If End Function Function fGetAnd(sStringToCheck) as String If Nz(Len(sStringToCheck),0)>0 Then fGetAnd = sStringToCheck & " AND " else fGetAnd = "" End If End Function Function fSetRecordSource() Dim strSQL as String strSQL = "SELECT NºProcesso, UltimaVersao, Nome, Contacto, AreaNegocio, Situação_processo, [Data Entrega_Montagem], Prazo_limite_ent_mont, [Estado Entrega_montagem], AssuntoNOficial FROM mapa2" & fGetWhere Me.RecordSource = strSQL End Function e agora onde as utilizo????
DreamPearl Posted May 6, 2009 at 04:41 PM Author Report #261899 Posted May 6, 2009 at 04:41 PM Ok já resolvi.... Dentro de cada evento de cada combo 'on change', fiz "call fSetRecordSource" Caso alguem precise aí esta o código
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now