ERRO DATA REPORT
Estou usando o código abaixo para carregar um data report só que esta me gerando o seguinte erro:
Run Time error -2147217904
nENHUM VALOR FOI FORNECIDO PARA UM OU MAIS PARÓ¡METROS NESCESSà ÂRIOS...
O codigo que estou usando é este:
Private Sub Image2_Click()
If txtdatainicial.Text = "" Then
MsgBox "Informe a data inicial", vbInformation, " Atenção!"
txtdatainicial.SetFocus
Exit Sub
ElseIf Len(txtdatainicial.Text) < 8 Then
MsgBox "Data inicial inválida", vbInformation, " Atenção!"
txtdatainicial.Text = ""
txtdatainicial.SetFocus
Exit Sub
ElseIf txtdatafinal.Text = "" Then
MsgBox "Informe a data final", vbInformation, " Atenção!"
txtdatafinal.SetFocus
Exit Sub
ElseIf Len(txtdatafinal.Text) < 8 Then
MsgBox "Data final inválida", vbInformation, " Atenção!"
txtdatafinal.Text = ""
txtdatafinal.SetFocus
Exit Sub
ElseIf CDate(txtdatainicial.Text) > CDate(txtdatafinal.Text) Then
MsgBox "A data final tem que ser igual ou superior a data inicial", vbInformation, " Atenção!"
txtdatafinal.Text = ""
txtdatafinal.SetFocus
Exit Sub
Else
Set Cnn = New ADODB.Connection
Set Rs = New ADODB.Recordset
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c: riade\Data\dbase.mdb;Jet OLEDB:Database Password=tmonrsr2308sbnu;"
Set Rs = Cnn.Execute("Select * from TabClientes where Nascimento >= #" & Format(txtdatainicial.Text, "mm / dd / yyyy") & "# and Data <= #" & Format(txtdatafinal.Text, " mm / dd / yyyy") & " #")
Set RelAniverssarios.DataSource = Rs
RelAniverssarios.Show
End If
End Sub
Run Time error -2147217904
nENHUM VALOR FOI FORNECIDO PARA UM OU MAIS PARÓ¡METROS NESCESSà ÂRIOS...
O codigo que estou usando é este:
Private Sub Image2_Click()
If txtdatainicial.Text = "" Then
MsgBox "Informe a data inicial", vbInformation, " Atenção!"
txtdatainicial.SetFocus
Exit Sub
ElseIf Len(txtdatainicial.Text) < 8 Then
MsgBox "Data inicial inválida", vbInformation, " Atenção!"
txtdatainicial.Text = ""
txtdatainicial.SetFocus
Exit Sub
ElseIf txtdatafinal.Text = "" Then
MsgBox "Informe a data final", vbInformation, " Atenção!"
txtdatafinal.SetFocus
Exit Sub
ElseIf Len(txtdatafinal.Text) < 8 Then
MsgBox "Data final inválida", vbInformation, " Atenção!"
txtdatafinal.Text = ""
txtdatafinal.SetFocus
Exit Sub
ElseIf CDate(txtdatainicial.Text) > CDate(txtdatafinal.Text) Then
MsgBox "A data final tem que ser igual ou superior a data inicial", vbInformation, " Atenção!"
txtdatafinal.Text = ""
txtdatafinal.SetFocus
Exit Sub
Else
Set Cnn = New ADODB.Connection
Set Rs = New ADODB.Recordset
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c: riade\Data\dbase.mdb;Jet OLEDB:Database Password=tmonrsr2308sbnu;"
Set Rs = Cnn.Execute("Select * from TabClientes where Nascimento >= #" & Format(txtdatainicial.Text, "mm / dd / yyyy") & "# and Data <= #" & Format(txtdatafinal.Text, " mm / dd / yyyy") & " #")
Set RelAniverssarios.DataSource = Rs
RelAniverssarios.Show
End If
End Sub
não utilize espaços no format:
vc colocou: "dd / mm / yyyy"
use:
"dd/mm/yyy"
vc colocou: "dd / mm / yyyy"
use:
"dd/mm/yyy"
Tirei os espaços mais não adiantou..Gera o mesmo erro...
faça assim:
antes de fazer o recordset, coloque:
msgbox "Select * from TabClientes where Nascimento >= #" & Format(txtdatainicial.Text, "mm/dd/yyyy") & "# and Data <= #" & Format(txtdatafinal.Text, "mm/dd/yyyy") & " #"
ou então tente assim
"SELECT * FROM TabClientes WHERE Nascimento BETWEEN '" & Format(txtdatainicial.Text, "mm/dd/yyyy") & "' AND '" & Format(txtdatafinal.Text, "mm/dd/yyyy")
antes de fazer o recordset, coloque:
msgbox "Select * from TabClientes where Nascimento >= #" & Format(txtdatainicial.Text, "mm/dd/yyyy") & "# and Data <= #" & Format(txtdatafinal.Text, "mm/dd/yyyy") & " #"
ou então tente assim
"SELECT * FROM TabClientes WHERE Nascimento BETWEEN '" & Format(txtdatainicial.Text, "mm/dd/yyyy") & "' AND '" & Format(txtdatafinal.Text, "mm/dd/yyyy")
Tópico encerrado , respostas não são mais permitidas