Thanks a lot Minty...You were right there were lots of undeclared variables...
buts its working fine now..heres the code..
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rstoid As DAO.Recordset
Dim strtoid As String, strtnid As String, struser As String, strreg As String, strtid As String...