Results 1 to 14 of 14
  1. #1
    adaoluz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    46

    Run-time error 3075

    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

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It looks like the control for Idorcamento is empty. I'd test for that first.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    adaoluz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    46
    I checked this was the empty field error, thank you!

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Code:
    rs1, rs2, rs3 As DAO.Recordset
    You seem to be making the classic multi variable one-line declaration error. Each variable must be explicitly declared (typed, meaning it's data type being set) otherwise the variable defaults to variant type. In your case, rs1 and rs2 are variants, not recordset objects. You'd want
    rs1 As DAO.Recordset, rs2 As DAO.Recordset, rs3 As DAO.Recordset

    Looks like you're not using those variables in the code sample anyway, so wondering why they are there. If you asked me if a variant can hold an object like a recordset, I'd have to say I don't know. So maybe if you leave it as is and try to assign another recordset later, maybe you'd get an error. On the other hand, a variant can hold the value Empty, which applies only to objects AFAIK, so maybe you'd be OK. Regardless, what you have is bad practice and could cause you grief one day.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by adaoluz View Post
    I checked this was the empty field error, thank you!
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    adaoluz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    46
    Hello !
    inserted manual data in the table "tblOrcamento", did not happen


    no mistake, I do not know if it's the right thing to do

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If that's a question, I think we're going to need more detail to figure it out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    adaoluz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    46
    Hello!
    I'm sending the database so it can be parsed


    when there is empty data, it gives error in the FrmOrcamento, when generating a new budget.
    Attached Files Attached Files

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    How does one recreate the error in the sample db?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    adaoluz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    46
    Hello!


    The error caused the error that there is no data in the form in the button generate budget, possibly


    I wanted to make this mistake, thank you.

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    To avoid the error add this at the beginning:

    Code:
        If Len(Me.IDOrcamento & vbNullString) = 0 Then
     .      MsgBox "No record"
            Exit Sub
        End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    adaoluz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    46
    Hello !


    this should solve the problem,


    Thank you!

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    adaoluz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Posts
    46
    to the next!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 01-04-2016, 09:40 AM
  2. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  3. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  4. Need Help with run time error 3075
    By vkumar in forum Forms
    Replies: 14
    Last Post: 07-24-2012, 05:48 PM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums