hteo sam da vas pitam samo dali neko zna neko bolje resenje od ovog posto sam video da bas ima mnogo razlicitih nacina da se uradi isto.
Code:
Sub unos()
Dim conn As New Connection
Dim rec As New Recordset
Dim sql As String
conn.Open "Provider=microsoft.jet.oledb.4.0;" + _
"Data Source=" + "C:\Documents and Settings\Korisnik\Desktop\db1.mdb;"
If VBA.DateTime.Time >= 0.708333333333333 Or VBA.DateTime.Time <= 4.16666666666667E-02 Then smena = 2
If VBA.DateTime.Time >= 4.16666666666667E-02 And VBA.DateTime.Time <= 0.375 Then smena = 3
If VBA.DateTime.Time <= 0.708333333333333 And VBA.DateTime.Time >= 0.375 Then smena = 1
For i = 0 To ListBox1.ListCount - 1
For j = 1 To ListBox1.List(i, 7)
sql = "insert into rad VALUES" & _
"(" & datum & "," _
& """" & Time() & """" & "," _
& smena & "," _
& ListBox1.List(i, 5) & "," _
& racunbr & "," _
& sifrakon & "," _
& sto & "," _
& ListBox1.List(i, 0) & "," _
& """" & ListBox1.List(i, 1) & """" & "," _
& """" & robastavka(ListBox1.List(i, 8), j, 2) & """" & "," _
& robastavka(ListBox1.List(i, 8), j, 3) * -1 & "," _
& ListBox1.List(i, 2) & "," _
& robastavka(ListBox1.List(i, 8), j, 1) & "," _
& ListBox1.List(i, 2) * robastavka(ListBox1.List(i, 8), j, 1) & "," _
& """" & ListBox1.List(i, 6) & """" & "," _
& """" & robastavka(ListBox1.List(i, 8), j, 4) & """" & "," _
& robastavka(ListBox1.List(i, 8), j, 5) & ")"
rec.Open sql, conn
Next j
Next i
conn.Close
End Sub
Sub unos()
Dim conn As New Connection
Dim rec As New Recordset
Dim sql As String
conn.Open "Provider=microsoft.jet.oledb.4.0;" + _
"Data Source=" + "C:\Documents and Settings\Korisnik\Desktop\db1.mdb;"
If VBA.DateTime.Time >= 0.708333333333333 Or VBA.DateTime.Time <= 4.16666666666667E-02 Then smena = 2
If VBA.DateTime.Time >= 4.16666666666667E-02 And VBA.DateTime.Time <= 0.375 Then smena = 3
If VBA.DateTime.Time <= 0.708333333333333 And VBA.DateTime.Time >= 0.375 Then smena = 1
For i = 0 To ListBox1.ListCount - 1
For j = 1 To ListBox1.List(i, 7)
sql = "insert into rad VALUES" & _
"(" & datum & "," _
& """" & Time() & """" & "," _
& smena & "," _
& ListBox1.List(i, 5) & "," _
& racunbr & "," _
& sifrakon & "," _
& sto & "," _
& ListBox1.List(i, 0) & "," _
& """" & ListBox1.List(i, 1) & """" & "," _
& """" & robastavka(ListBox1.List(i, 8), j, 2) & """" & "," _
& robastavka(ListBox1.List(i, 8), j, 3) * -1 & "," _
& ListBox1.List(i, 2) & "," _
& robastavka(ListBox1.List(i, 8), j, 1) & "," _
& ListBox1.List(i, 2) * robastavka(ListBox1.List(i, 8), j, 1) & "," _
& """" & ListBox1.List(i, 6) & """" & "," _
& """" & robastavka(ListBox1.List(i, 8), j, 4) & """" & "," _
& robastavka(ListBox1.List(i, 8), j, 5) & ")"
rec.Open sql, conn
Next j
Next i
conn.Close
End Sub