Prikazi cijelu temu 01.10.2012 12:30
pmiroslav Van mreze
Clan
Registrovan od:02.02.2009
Lokacija:Osijek


Predmet:Re: Funkcija molim pomoć
Uspio sam na kraju ovako:

PreuzmiIzvorni kôd (vbnet):
  1. Function Storniraj(OrderID As String)
  2. On Error GoTo Err_Storniraj
  3. Dim Db As Database
  4. Dim Rs1 As Recordset
  5. Dim Rs2 As Recordset
  6. Dim Rs3 As Recordset
  7. Dim SQL1 As String
  8. Dim SQL2 As String
  9. Dim SQL3 As String
  10. Dim IDTransakcije As Integer
  11. Set rcs = Nothing
  12. Set Db = CurrentDb()
  13. If Not IsNull(DLookup("[IDtransakcije]", "TblTransakcije", "[BrDokumenta] ='" & OrderID & "'")) Then
  14.     IDTransakcije = DLookup("[IDtransakcije]", "TblTransakcije", "[BrDokumenta] ='" & OrderID & "'")
  15.     SQL1 = "SELECT * FROM tblTransakcije WHERE BrDokumenta='" & OrderID & "'"
  16.     SQL2 = "SELECT * FROM tblUlazIzlaz WHERE IDTransakcije=" & IDTransakcije
  17.     Set Rs1 = Db.OpenRecordset(SQL1, dbOpenDynaset)
  18.     Set Rs2 = Db.OpenRecordset(SQL2, dbOpenDynaset)
  19.     If Rs1.RecordCount > 0 Then
  20.     Do While Not Rs1.EOF
  21.     Rs1.Edit
  22.     Rs1!Brisanje = 0
  23.     Rs1.Update
  24.     Rs1.MoveNext
  25.     Loop
  26. End If
  27. If Rs2.RecordCount > 0 Then
  28.     Do While Not Rs2.EOF
  29.     Rs2.Edit
  30.     Rs2!Status = 0
  31.     Rs2.Update
  32.     Rs2.MoveNext
  33.     Loop
  34. End If
  35.     SQL3 = "SELECT * FROM tblProdaja WHERE OrderID='" & OrderID & "'"
  36.     Set Rs3 = Db.OpenRecordset(SQL3, dbOpenDynaset)
  37. If Rs3.RecordCount > 0 Then
  38.     Do While Not Rs3.EOF
  39.     Rs3.Edit
  40.     Rs3!Proknjizeno = False
  41.     Rs3!Stornirano = 0
  42.     Rs3.Update
  43.     Rs3.MoveNext
  44.     Loop
  45. End If
  46.     Rs1.Close
  47.     Rs2.Close
  48.     Rs3.Close
  49. Else
  50.     SQL3 = "SELECT * FROM tblProdaja WHERE OrderID='" & OrderID & "'"
  51.     Set Rs3 = Db.OpenRecordset(SQL3, dbOpenDynaset)
  52. If Rs3.RecordCount > 0 Then
  53.     Do While Not Rs3.EOF
  54.     Rs3.Edit
  55.     Rs3!Proknjizeno = False
  56.     Rs3!Stornirano = 0
  57.     Rs3.Update
  58.     Rs3.MoveNext
  59.     Loop
  60.     End If
  61.     Rs3.Close
  62.     End If
  63.     Set Db = Nothing
  64. Izlaz:
  65. Exit Function
  66. Err_Storniraj:
  67. MsgBox "Greska broj " & err.Number & vbCrLf & err.Description & vbCrLf & "u funkciji Storniraj()"
  68. Kraj:
  69. End Function

Dodao sam :
If Not Is Null (...) Then

Else

End if

I sada je sve u redu.
Pozdrav