Re: Better Coding 2 SQL Commands



DS wrote:

I have to run 2 SQL commands, This is what I came up with but I'm sure there is a cleaner way. It works but cleaner would be better!
Thanks
DS


Private Sub Command4_Click()

CurrentDb.Execute "INSERT INTO JobsDept(DeptID,JobID) VALUES(" & Forms!DeepJob!DepartmentID & ", " & Me.List0.Column(0) & ")"


Dim MySQL As String DoCmd.SetWarnings False MySQL = "UPDATE JobNames SET [Assigned] = True " & _ "WHERE [JobNameID] = Forms!JobPicker![Text6]; " DoCmd.RunSQL (MySQL) DoCmd.SetWarnings True

    DoCmd.Close acForm, "JobPicker"
    Forms!DeepJob.List44.Requery
End Sub

What are you trying to clean up? It looks as if you're making changes to two different Tables. It's not unreasonable to have to use two SQL statements to do that, so I don't see any obvious way to combine them. Or were you considering doing something else?


  -- Vincent Johns <vjohns@xxxxxxxxxxxxxxxxxx>
  Please feel free to quote anything I say here.
.



Relevant Pages

  • Re: Relational-to-OOP Tax
    ... depending on the size of the SQL statements ... Regardless if your code contains SQL statements or not: ... insert into employee values ... It is cleaner when createEmployeeis more realistically imagined: ...
    (comp.object)
  • Re: Relational-to-OOP Tax
    ... Forcing all SQL statements into functions instead of only putting them ... cleaner or more well-factored code. ... Clean code is easier to maintain and extend. ... The decoupling you are talkning about is only about creating extra ...
    (comp.object)
  • Re: reading symbols preserving case
    ... funcalls the function associated with backquote. ... It does the trick, but ... I'd like something cleaner, if possible. ... There's a QUOTE special operator ...
    (comp.lang.lisp)

Loading