K
Kowsy
I have the code that looks like below.Actually i have to update the table
iwth certain conditions.
If Ptyp field in the table is "PGR" then it should grab the next row's [strt
tm] value and put in the current row [end tm] value if not it has to do some
manipulations as show in the code.
I am not able to geb the next row [strt tm] and it is putting the same [strt
tm] in the current row
--------
Function Changeendtm()
Dim TableName As String
Dim NumRecords As Long
Dim i As Long
Dim DB As DAO.Database, TABLE As DAO.Recordset
TableName = "tblMovie"
Set Rst = CurrentDb.OpenRecordset("select * from [tblMovie]", dbOpenDynaset)
Set DB = CurrentDb
Set TABLE = DB.OpenRecordset(TableName, dbOpenTable)
NumRecords = Rst.RecordCount
Do Until TABLE.EOF
For i = 1 To NumRecords
If TABLE![ptyp] = "pgr" Then
TABLE.Edit
TABLE![END TM] = Format(CLng(TABLE![STRT TM]), "000000")
TABLE.Update
Else
TABLE.Edit
TABLE![END TM] = Format(CLng(TABLE![STRT TM]) + CLng(TABLE![DUR]), "000000")
TABLE.Update
End If
TABLE.MoveNext
Next i
Loop
Rst.Close
Set Rst = Nothing
DB.Close
Set DB = Nothing
End Function
Thanks in advance
iwth certain conditions.
If Ptyp field in the table is "PGR" then it should grab the next row's [strt
tm] value and put in the current row [end tm] value if not it has to do some
manipulations as show in the code.
I am not able to geb the next row [strt tm] and it is putting the same [strt
tm] in the current row
--------
Function Changeendtm()
Dim TableName As String
Dim NumRecords As Long
Dim i As Long
Dim DB As DAO.Database, TABLE As DAO.Recordset
TableName = "tblMovie"
Set Rst = CurrentDb.OpenRecordset("select * from [tblMovie]", dbOpenDynaset)
Set DB = CurrentDb
Set TABLE = DB.OpenRecordset(TableName, dbOpenTable)
NumRecords = Rst.RecordCount
Do Until TABLE.EOF
For i = 1 To NumRecords
If TABLE![ptyp] = "pgr" Then
TABLE.Edit
TABLE![END TM] = Format(CLng(TABLE![STRT TM]), "000000")
TABLE.Update
Else
TABLE.Edit
TABLE![END TM] = Format(CLng(TABLE![STRT TM]) + CLng(TABLE![DUR]), "000000")
TABLE.Update
End If
TABLE.MoveNext
Next i
Loop
Rst.Close
Set Rst = Nothing
DB.Close
Set DB = Nothing
End Function
Thanks in advance