Ver Mensaje Individual
  #3 (permalink)  
Antiguo 27/11/2007, 09:29
yohannita
 
Fecha de Ingreso: noviembre-2007
Mensajes: 39
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: error 3021 en tiempo de ejecucion

he estado modificando el codigo ..... pero no encuentro la solucion !!! te envio el
codigo.... haber si m puedes ayudar......

Private Sub btn_save_Click()
Dim weekRepId As Integer
Dim appProfile As Integer
Dim projId As String
Dim actId As String
Dim comp As Integer
Dim siExiste As Boolean
Dim countreg As Integer

If Text1.Visible Then
fgd_timesheet = Text1
Text1.Visible = False
RecalcTotal (fgd_timesheet.Col)
End If

'checa si ya esta cerrado el registro
Set rst = New ADODB.Recordset
strSQL = " SELECT distinct id " & _
" FROM current_week_report, current_daily_entry " & _
" WHERE id = week_report_id " & _
" AND signature = '" & TRUser & "' " & _
" AND current_week_report.week_id = " & txt_week & " " & _
" AND completed = 1 "
rst.Open strSQL, de_TimeReportDB.cnn_TimeReportDB, adOpenStatic, adLockReadOnly, adCmdText

If Not rst.EOF Then Exit Sub

' clean up
rst.Close
Set rst = Nothing

countreg = 0
'adquiere el week_report_id
Set rst = New ADODB.Recordset
strSQL = " SELECT distinct id " & _
" FROM current_week_report, current_daily_entry " & _
" WHERE id = week_report_id " & _
" AND signature = '" & TRUser & "' " & _
" AND current_week_report.week_id = " & txt_week & " " & _
" AND completed = 0 " & _
" AND current_week_report.approved = 0 "
rst.Open strSQL, de_TimeReportDB.cnn_TimeReportDB, adOpenStatic, adLockReadOnly, adCmdText

siExiste = False

Do While Not rst.EOF
siExiste = True
weekRepId = Val(rst!id)
rst.MoveNext
Loop

' clean up
rst.Close
Set rst = Nothing

If siExiste = True Then
'Elimina registros
strSQL = "Delete from current_daily_entry where week_report_id = " & weekRepId & " "
de_TimeReportDB.cnn_TimeReportDB.Execute strSQL
Else
'si no existe el registro sacar week_report_id
Set rst = New ADODB.Recordset
rst.Open "select MAX(id) from current_week_report", de_TimeReportDB.cnn_TimeReportDB, , , adCmdText
weekRepId = Val(rst.GetString) + 1
rst.Close
'sacar el apprProfile
Set rst = New ADODB.Recordset
rst.Open "select id from appusr_profile where appr_dept_id = '" & TRDept & "' and isDrag=1 ", de_TimeReportDB.cnn_TimeReportDB, , , adCmdText
appProfile = Val(rst.GetString) //aqui marca el error....
rst.Close
'Escribe registro en current_week_report
strSQL = "Insert into current_week_report values (" & weekRepId & "," & _
appProfile & "," & txt_week & ",0)"
de_TimeReportDB.cnn_TimeReportDB.Execute strSQL
End If



gracias