ACCESS DATA/HORA TRATAR COMO VAZIA

MARCELOFAZAN 18/06/2010 14:14:41
#345204
Pessoal , Nao tem fazer algo assim


Item.SubItems(1) = IIf(rs([Ô]data[Ô]) = True, MsgBox([ô]Selecione Corretamente uma Data[ô]), rs([Ô]data[Ô]))
Item.SubItems(2) = [Ô][Ô] & rs([Ô]NOME[Ô])
Item.SubItems(3) = IIf(IsNull(rs([Ô]hora[Ô])) = True, MsgBox([ô]Selecione Corretamente uma Hora[ô]), rs([Ô]hora[Ô]))

ou mesmo assim

filtro = [Ô]where Data=#[Ô] & Format(TxtCriterio.Text, [Ô]mm/dd/yyyy[Ô]) & [Ô]#[Ô] and (txtcriterio.text = [Ô][ô] , MsgBox([ô]Selecione Corretamente uma Data[ô]))

filtro = [Ô]where nome like [ô]%[Ô] & TxtCriterio.Text & [Ô]%[ô][Ô]
filtro = [Ô]where Hora=#[Ô] & Format(TxtCriterio.Text, [Ô]hh:nn:ss[Ô]) & [Ô]#[Ô] and (txtcriterio.text =[Ô][Ô] , MsgBox([ô]Selecione Corretamente uma Hora[ô]))


outra solucao seria usar a funcao somente no criterio case 2 data


to usando essa funcao para validar data so que nao consiguiria ajustar conforme os criterios
, tenho as opcoes do combo, Nome Data
o Hora capaz que vo tirar , pois se nao buscar o segundos, ja nao fica boa consulta,

mais questao no combo seleciono Data ai pro Txt criterio acionar essa funcao

so que como vo reconheccer pra que o item do combo somente fuincione pra essa funcao poderia tb ser


filtro = [Ô]where Data=#[Ô] & Format(TxtCriterio.Text, [Ô]mm/dd/yyyy[Ô]) & [Ô]#[Ô]

e Item.SubItems(1) = IIf(IsNull(Rs([Ô]data[Ô])) = True, [Ô][Ô], Rs([Ô]data[Ô]))

como ajustaria com o combo esse codigo

Private Sub txtData_KeyPress(KeyAscii As Integer)
CampoDATA TxtData, KeyAscii
End Sub



CmbCriterio.AddItem [Ô]Todos[Ô] [ô]0
CmbCriterio.AddItem [Ô]Data[Ô] [ô]1
CmbCriterio.AddItem [Ô]nome[Ô] [ô]2
CmbCriterio.AddItem [Ô]hora[Ô] [ô]3 ???

Abs
Obg
Marcelo FAzan

MARCELO.TREZE 18/06/2010 18:39:07
#345227
Vamos lá pelo que vc disse isso não resolveria

Select Case CmbCriterio.ListIndex
Case 0
filtro = [Ô][Ô]
Case 1
If TxtCriterio = Empty Then
Msgbox [Ô]O ampo data não pode ser vazio![Ô]
TxtCriterio.SetFocus
Exit Sub
Else
filtro = [Ô]where Data=#[Ô] & Format(TxtCriterio.Text, [Ô]mm/dd/yyyy[Ô]) & [Ô]#[Ô]
End If
Case 2
filtro = [Ô]where nome like [ô]%[Ô] & TxtCriterio.Text & [Ô]%[ô][Ô]
Case 3
filtro = [Ô]where Hora=#[Ô] & Format(TxtCriterio.Text, [Ô]hh:nn:ss[Ô]) & [Ô]#[Ô]
End Select

Sql = [Ô] Select * from frequencia [Ô] & filtro
rs.Open Sql, conexao

LsvBusca.ListItems.Clear

Do While Not rs.EOF
Set Item = LsvBusca.ListItems.Add(, , rs([Ô]id[Ô]))
Item.SubItems(1) = IIf(rs([Ô]data[Ô]) = True, [Ô][Ô], rs([Ô]data[Ô]))
Item.SubItems(2) = [Ô][Ô] & rs([Ô]NOME[Ô])
Item.SubItems(3) = IIf(IsNull(rs([Ô]hora[Ô])) = True, [Ô][Ô], rs([Ô]hora[Ô]))
rs.MoveNext
Loop


testa o código acima
Página 3 de 3 [22 registro(s)]
Tópico encerrado , respostas não são mais permitidas