Hello .. Good evening!
Could you please help me with the error "Run-time error 3075", 'Syntax error (operator missing) in query expression ' Idorcamento= '
highlighted line with the error description.
Code:
Private Sub bt_gerarPedido_Click()Dim dbOrc As Database, rs1, rs2, rs3 As DAO.Recordset
If MsgBox("Deseja Gerar Caixa desse Orçamento?", vbYesNo + vbQuestion, Me.Caption) = vbNo Then
Me.Undo
DoCmd.CancelEvent
MsgBox "Não foi gerado caixa !", vbInformation, Me.Caption
Exit Sub
Else
Set dbOrc = CurrentDb
Set rs1 = dbOrc.OpenRecordset("tblcaixa")
With rs1
.AddNew
![IDOrcamento] = Me.IDOrcamento
![DataPagamento] = Me.DataOrcamento
![Proprietario] = Me.Proprietario
![Telefone] = Me.Telefone
![Celular] = Me.Celular
![Animal] = Me.Animal
![Valor] = Me.Valorf
![IdProp] = Me.IdProp
.Update
End With
Set rs2 = dbOrc.OpenRecordset("SELECT * FROM TblSubOrcamento WHERE Idorcamento=" & Me.IDOrcamento)
Set rs3 = dbOrc.OpenRecordset("tblsubcaixa")
While (Not rs2.EOF)
With rs3
.AddNew
![IdCaixa] = DMax("idcaixa", "tblcaixa")
![IDOrcamento] = rs2![IDOrcamento]
![Servico] = rs2![Servico]
![Custo] = rs2![Custo]
![Qtd] = rs2![Qtd]
![Tcusto] = rs2![TotalProc]
.Update
rs2.MoveNext
End With
Wend
rs1.Close
Set rs1 = Nothing
rs2.Close
Set rs2 = Nothing
rs3.Close
Set rs3 = Nothing
Set dbOrc = Nothing
'limpa a tblorcamento no orçamento especifico que gerou o caixa, evitando duplicatas na tbl
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close acForm, "frmorcamento"
DoCmd.OpenForm "frmcaixa"
End If
End Sub