IF
A minha dificuldade nesse cod. esta onde salientado, quero que se o campo da tabela estiver vazio me retorne "0" só que esta dando a mensagem (No current record). Alguem tem uma dica?
Private Sub CmdBusca_Click()
Dim Sql As String
Dim Val As String
Sql = "SELECT * FROM Baixas WHERE Codigo like '*" & TxtBusca.Text & "*'"
Set tbOs2 = bdMat2.OpenRecordset(Sql)
''Val = "SELECT * FROM Localizacao WHERE Código like '*" & TxtBusca.Text & "*'"
''Set tbOs3 = bdMat2.OpenRecordset(Val)
Val = "SELECT Quantidade, Unitario FROM Localizacao WHERE Código = '" & TxtBusca.Text & "'"
Set tbOs3 = bdMat2.OpenRecordset(Val)
If tbOs2.RecordCount = 0 Then
DbList_3.Clear
Else
DbList_3.Clear
tbOs2.MoveLast
tbOs2.MoveFirst
Dim i, J
i = 0
J = 1
Do Until tbOs2.EOF
DbList_3.AddItem Alinha(Format(tbOs2("Codigo"), "000000"), 6, "ESQ")
DbList_3.List(i, 1) = tbOs2("Saida")
DbList_3.List(i, 2) = tbOs2("Data")
DbList_3.List(i, 3) = tbOs2("Req")
DbList_3.List(i, 4) = Alinha(tbOs2("OS"), 10, "DIR")
i = i + 1
a = a + CDbl(tbOs2("Saida"))
tbOs2.MoveNext
Loop
End If
Lbsaida = CStr(a)
Lb_Entrada = tbOs3!Quantidade
If tbOs2!Saida = Empty Then
Lbsaida = 0
Else
LbSaldo = tbOs3!Quantidade - tbOs2!Saida
End If
LbV_Entrada = Lb_Entrada * tbOs3!Unitario
LbV_Saida = Lbsaida * tbOs3!Unitario
LbV_Saldo = LbSaldo * tbOs3!Unitario
LbV_Saldo = Format(LbV_Saldo.Caption, "#,###,##0.00")
LbV_Saida = Format(LbV_Saida.Caption, "#,###,##0.00")
LbV_Entrada = Format(LbV_Entrada.Caption, "#,###,##0.00")
TxtBusca.Text = ""
TxtBusca.SetFocus
End Sub[txt-color=red][/txt-color]
Private Sub CmdBusca_Click()
Dim Sql As String
Dim Val As String
Sql = "SELECT * FROM Baixas WHERE Codigo like '*" & TxtBusca.Text & "*'"
Set tbOs2 = bdMat2.OpenRecordset(Sql)
''Val = "SELECT * FROM Localizacao WHERE Código like '*" & TxtBusca.Text & "*'"
''Set tbOs3 = bdMat2.OpenRecordset(Val)
Val = "SELECT Quantidade, Unitario FROM Localizacao WHERE Código = '" & TxtBusca.Text & "'"
Set tbOs3 = bdMat2.OpenRecordset(Val)
If tbOs2.RecordCount = 0 Then
DbList_3.Clear
Else
DbList_3.Clear
tbOs2.MoveLast
tbOs2.MoveFirst
Dim i, J
i = 0
J = 1
Do Until tbOs2.EOF
DbList_3.AddItem Alinha(Format(tbOs2("Codigo"), "000000"), 6, "ESQ")
DbList_3.List(i, 1) = tbOs2("Saida")
DbList_3.List(i, 2) = tbOs2("Data")
DbList_3.List(i, 3) = tbOs2("Req")
DbList_3.List(i, 4) = Alinha(tbOs2("OS"), 10, "DIR")
i = i + 1
a = a + CDbl(tbOs2("Saida"))
tbOs2.MoveNext
Loop
End If
Lbsaida = CStr(a)
Lb_Entrada = tbOs3!Quantidade
If tbOs2!Saida = Empty Then
Lbsaida = 0
Else
LbSaldo = tbOs3!Quantidade - tbOs2!Saida
End If
LbV_Entrada = Lb_Entrada * tbOs3!Unitario
LbV_Saida = Lbsaida * tbOs3!Unitario
LbV_Saldo = LbSaldo * tbOs3!Unitario
LbV_Saldo = Format(LbV_Saldo.Caption, "#,###,##0.00")
LbV_Saida = Format(LbV_Saida.Caption, "#,###,##0.00")
LbV_Entrada = Format(LbV_Entrada.Caption, "#,###,##0.00")
TxtBusca.Text = ""
TxtBusca.SetFocus
End Sub[txt-color=red][/txt-color]
Ola!!
Nao entendi mas ve se isso ajuda
if isnull(tbOs2!Saida) = true then
Lbsaida = 0
endif
if tbOS2.eof = true then
Lbsaida = 0
endif
Nao entendi mas ve se isso ajuda
if isnull(tbOs2!Saida) = true then
Lbsaida = 0
endif
if tbOS2.eof = true then
Lbsaida = 0
endif
Tópico encerrado , respostas não são mais permitidas