Bosna i Hercegovina



#1 19.06.2012-09:25
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Subject: Pomoć recordest
Opet imama jedan mali problemčić.
napravio sam slijedeći kod za upis cijene koštanja u tablicu u kojoj već postoje podaci.
Problem je kada u tablici imam više redova koji zadovoljavaju kriterij isti ID i isti broj komada, cijena se upiše sami u prvi red.
DownloadIzvorni kod (vb.net):
  1. Private Sub C_Upisi_Click()
  2. Dim Db As Database
  3. Dim Rs As Recordset
  4. Dim Podatak As Currency
  5. Dim SQL As String
  6. Dim Ident As String
  7. Dim Kom As Integer
  8. Ident = Me.ID
  9. Kom = Quantity()
  10. Set Db = CurrentDb()
  11. Podatak = Me.CK
  12. SQL = "SELECT * FROM tblNalog WHERE ID ='" & ID & "'AND Komada =" & Kom
  13. Set Rs = Db.OpenRecordset(SQL, dbOpenDynaset)
  14. With Rs
  15. If .RecordCount > 0 Then
  16. .MoveFirst
  17. .Edit
  18. !Vrijednost = Podatak
  19. .Update
  20. .MoveNext
  21. End If
  22. End With

Pozdrav
↑  ↓

#2 19.06.2012-11:49
zxz Offline
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,507


Subject: Re: Pomoć recordest
DownloadIzvorni kod (SQL):
  1. Private Sub C_Upisi_Click()
  2. Dim Db AS DATABASE
  3. Dim Rs AS Recordset
  4. Dim Podatak AS Currency
  5. Dim SQL AS String
  6. Dim Ident AS String
  7. Dim Kom AS Integer
  8.  
  9. Ident = Me.ID
  10. Kom = Quantity()
  11. SET Db = CurrentDb()
  12. Podatak = Me.CK
  13. SQL = "SELECT * FROM tblNalog WHERE ID ='" & ID & "'AND Komada =" & Kom
  14. SET Rs = Db.OpenRecordset(SQL, dbOpenDynaset)
  15.  
  16. IF .RecordCount > 0 Then
  17. do while NOT Rs.eof
  18. Rs.Edit
  19. RS!Vrijednost = Podatak
  20. RS.UPDATE
  21. RS.MoveNext
  22. loop
  23. End IF
  24. Rs.close
  25. SET db=Nothing
  26. end sub

Pozdrav
↑  ↓

#3 19.06.2012-13:56
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Subject: Re: Pomoć recordest
Ovo mi prekine proceduru u liniji
If .RecordCount > 0 Then

sa porukom 'Invalid or unqualified reference'
Pozdrav
↑  ↓

#4 19.06.2012-14:13
zxz Offline
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,507


Subject: Re: Pomoć recordest
Citat:
If Rs.RecordCount > 0 Then
Kucao sa na forumu pa zaboravio ispraviti.
Pozdrav
↑  ↓

Stranice (1): 1


All times are GMT +01:00. Current time: 14.12.2017-01:18.