By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,401 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

error 3021

P: 2
i am doing a vb project, i am getting error code 3021, when click doc1, this error occures,
code below
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDoc1_Due_Click()
  2.     Dim sysd As Date
  3.     sysd = Format(Date, "dd-MMM-yy")
  4.     Dim Row_Var As Integer
  5.     Dim VhclNo As String
  6.     Dim date1, strQueryDoc1Chk, strRecordFind, strQuerySM As String
  7.     Dim rsDoc1Chk As New ADODB.Recordset
  8.     Dim rsRecordFind As New ADODB.Recordset
  9.     Row_Var = 1
  10.     Call ConnOpen
  11.     strQuery = "SELECT ppmk_vhcl_no, max(ppmk_date) AS DateMax FROM preventive_prgm_maint_kms WHERE ppmk_date <= '" & UCase(sysd) & "' GROUP BY ppmk_vhcl_no ORDER BY ppmk_vhcl_no"
  12.     rsSlno.Open (strQuery), gcnn, adOpenDynamic, adLockOptimistic
  13.     Dim rsVhclMake As New ADODB.Recordset
  14.     Dim VEHMAKE As String
  15.  
  16.     While Not rsSlno.EOF
  17.         Dim Vhcl_no As String
  18.         Dim maxdate As String
  19.         Vhcl_no = rsSlno("ppmk_vhcl_no")
  20.         maxdate = rsSlno("DateMax")
  21.         strRecordFind = "SELECT ppmk_vhcl_status FROM preventive_vehicle_master WHERE ppmk_vhcl_no = '" & Vhcl_no & "'"
  22.         rsRecordFind.Open (strRecordFind), gcnn, adOpenDynamic, adLockOptimistic
  23.         If (rsRecordFind("ppmk_vhcl_status") = "AA") Then
  24.             GoTo lblnext
  25.         End If
  26.         If (rsRecordFind("ppmk_vhcl_status") = "VT_PERM") Then
  27.             GoTo skip_slno
  28.         End If
  29.         If (rsRecordFind("ppmk_vhcl_status") = "SCRP") Then
  30.             GoTo skip_slno
  31.         End If
  32. lblnext:
  33.         rsVhclMake.Open "SELECT ppmk_vhcl_make FROM preventive_vehicle_master WHERE ppmk_vhcl_no = '" & Vhcl_no & "'", gcnn, adOpenDynamic, adLockOptimistic
  34.         VEHMAKE = rsVhclMake("ppmk_vhcl_make")
  35.         strQuery3 = "SELECT * FROM preventive_prgm_maint_kms WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date = '" & maxdate & "'"
  36.         rsdoc.Open (strQuery3), gcnn, adOpenDynamic, adLockOptimistic
  37.  
  38.         While Not rsdoc.EOF
  39.             If UCase(rsdoc("ppmk_dock_compltd")) = "DOC1" Then
  40.                 rsdoc.Close
  41.                 rsVhclMake.Close
  42.                 GoTo skip_slno
  43.             Else
  44.                 strQueryDoc1Chk = "SELECT * FROM preventive_prgm_maint_kms WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date <= '" & maxdate & "' ORDER BY ppmk_date DESC"
  45.                 rsDoc1Chk.Open (strQueryDoc1Chk), gcnn, adOpenDynamic, adLockOptimistic
  46.  
  47.                 Do While Not rsDoc1Chk.EOF
  48.                     If UCase(rsDoc1Chk("ppmk_dock2_compltd")) = "DOC2" Then
  49.                         Exit Do
  50.                     End If
  51.                     If UCase(rsDoc1Chk("ppmk_dock_compltd")) = "DOC1" Then
  52.                         rsDoc1Chk.Close
  53.                         rsdoc.Close
  54.                         rsVhclMake.Close
  55.                         GoTo skip_slno
  56.                         Exit Do
  57.                     End If
  58.                     rsDoc1Chk.MoveNext
  59.                 Loop
  60.                 rsDoc1Chk.Close
  61.             End If
  62.             rsdoc.MoveNext
  63.         Wend
  64.         rsdoc.Close
  65.         rsVhclMake.Close
  66.         Dim rsSMveh As New ADODB.Recordset
  67.         rsSMveh.Open ("SELECT ppmk_start_km_doc1 FROM preventive_prgm_maint_kms WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date = '" & maxdate & "'"), gcnn, adOpenDynamic, adLockOptimistic
  68.         If (rsSMveh("ppmk_start_km_doc1") > 13000 And VEHMAKE = "SM") Then
  69.             'strQuerySM = "UPDATE preventive_prgm_maint_kms SET PPMK_SLNO=" & Row_Var & " WHERE PPMK_VHCL_NO='" & Vhcl_no & "' and ppmk_date='" & maxdate & "'"
  70.             strQuerySM = "UPDATE preventive_prgm_maint_kms SET ppmk_slno = " & Row_Var & " WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date = '" & maxdate & "' AND ppmk_start_km_doc1 BETWEEN 13000 AND 20000 "
  71.             gcnn.Execute (strQuerySM)
  72.             GoTo rowincr
  73.         End If
  74.         StrQuery1 = "UPDATE preventive_prgm_maint_kms SET ppmk_slno = " & Row_Var & " WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date = '" & maxdate & "' AND ppmk_start_km_doc1 BETWEEN 18000 AND 25000 "
  75.         gcnn.Execute (StrQuery1)
  76. rowincr:
  77.         Row_Var = Row_Var + 1
  78.         rsSMveh.Close
  79. skip_slno:
  80.         rsSlno.MoveNext
  81.         rsRecordFind.Close
  82.     Wend
  83.     rsSlno.Close
  84.     Dim strQueryKmDesc As String
  85.     Dim rsKmSlno As New ADODB.Recordset
  86.     Dim vardesc, veh_slno As Integer
  87.     Dim veh_no As String
  88.     vardesc = 1
  89.     strQueryKmDesc = "SELECT * FROM preventive_prgm_maint_kms WHERE ppmk_slno IS NOT NULL ORDER BY ppmk_start_km_doc1 DESC"
  90.     rsKmSlno.Open (strQueryKmDesc), gcnn, adOpenDynamic, adLockOptimistic
  91.     While Not rsKmSlno.EOF
  92.         veh_no = rsKmSlno("ppmk_vhcl_no")
  93.         veh_slno = rsKmSlno("ppmk_slno")
  94.         gcnn.Execute ("UPDATE preventive_prgm_maint_kms SET ppmk_slno = " & vardesc & " WHERE ppmk_vhcl_no = '" & veh_no & "' AND ppmk_slno = '" & veh_slno & "'")
  95.         rsKmSlno.MoveNext
  96.         vardesc = vardesc + 1
  97.     Wend
  98.     rsKmSlno.Close
  99.     Load deVMS
  100.     With deVMS
  101.         If .rsCommand2_Grouping.State <> 0 Then .rsCommand2_Grouping.Close
  102.         '.Command2 CDate(sysd)
  103.     End With
  104.     DataReport2.Refresh
  105.     If DataReport2.Visible = False Then DataReport2.Show
  106.     strQuery2 = "UPDATE preventive_prgm_maint_kms SET ppmk_slno = ''"
  107.     gcnn.Execute (strQuery2)
  108.     Call ConnClose
  109.  
  110. End Sub
Dec 11 '07 #1
Share this Question
Share on Google+
3 Replies


debasisdas
Expert 5K+
P: 8,127
Place brake point and check in debug mode exactly which line of code is creating the problem.

It seems there is no record in the database.
Dec 11 '07 #2

QVeen72
Expert 100+
P: 1,445
Hi,

What Point /Line of the code, you are getting error...?
Try changing to : "Do While Not rsSlno.EOF" .... Loop
Instead of While Not..

Regards
Veena
Dec 11 '07 #3

P: 2
i am doing a vb project, i am getting error code 3021, when click doc1, this error occures, i am geeting error in line 23 code is
( If (rsRecordFind("ppmk_vhcl_status") = "AA") Then)
code below
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDoc1_Due_Click()
  2.     Dim sysd As Date
  3.     sysd = Format(Date, "dd-MMM-yy")
  4.     Dim Row_Var As Integer
  5.     Dim VhclNo As String
  6.     Dim date1, strQueryDoc1Chk, strRecordFind, strQuerySM As String
  7.     Dim rsDoc1Chk As New ADODB.Recordset
  8.     Dim rsRecordFind As New ADODB.Recordset
  9.     Row_Var = 1
  10.     Call ConnOpen
  11.     strQuery = "SELECT ppmk_vhcl_no, max(ppmk_date) AS DateMax FROM preventive_prgm_maint_kms WHERE ppmk_date <= '" & UCase(sysd) & "' GROUP BY ppmk_vhcl_no ORDER BY ppmk_vhcl_no"
  12.     rsSlno.Open (strQuery), gcnn, adOpenDynamic, adLockOptimistic
  13.     Dim rsVhclMake As New ADODB.Recordset
  14.     Dim VEHMAKE As String
  15.  
  16.     While Not rsSlno.EOF
  17.         Dim Vhcl_no As String
  18.         Dim maxdate As String
  19.         Vhcl_no = rsSlno("ppmk_vhcl_no")
  20.         maxdate = rsSlno("DateMax")
  21.         strRecordFind = "SELECT ppmk_vhcl_status FROM preventive_vehicle_master WHERE ppmk_vhcl_no = '" & Vhcl_no & "'"
  22.         rsRecordFind.Open (strRecordFind), gcnn, adOpenDynamic, adLockOptimistic
  23.         If (rsRecordFind("ppmk_vhcl_status") = "AA") Then
  24.             GoTo lblnext
  25.         End If
  26.         If (rsRecordFind("ppmk_vhcl_status") = "VT_PERM") Then
  27.             GoTo skip_slno
  28.         End If
  29.         If (rsRecordFind("ppmk_vhcl_status") = "SCRP") Then
  30.             GoTo skip_slno
  31.         End If
  32. lblnext:
  33.         rsVhclMake.Open "SELECT ppmk_vhcl_make FROM preventive_vehicle_master WHERE ppmk_vhcl_no = '" & Vhcl_no & "'", gcnn, adOpenDynamic, adLockOptimistic
  34.         VEHMAKE = rsVhclMake("ppmk_vhcl_make")
  35.         strQuery3 = "SELECT * FROM preventive_prgm_maint_kms WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date = '" & maxdate & "'"
  36.         rsdoc.Open (strQuery3), gcnn, adOpenDynamic, adLockOptimistic
  37.  
  38.         While Not rsdoc.EOF
  39.             If UCase(rsdoc("ppmk_dock_compltd")) = "DOC1" Then
  40.                 rsdoc.Close
  41.                 rsVhclMake.Close
  42.                 GoTo skip_slno
  43.             Else
  44.                 strQueryDoc1Chk = "SELECT * FROM preventive_prgm_maint_kms WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date <= '" & maxdate & "' ORDER BY ppmk_date DESC"
  45.                 rsDoc1Chk.Open (strQueryDoc1Chk), gcnn, adOpenDynamic, adLockOptimistic
  46.  
  47.                 Do While Not rsDoc1Chk.EOF
  48.                     If UCase(rsDoc1Chk("ppmk_dock2_compltd")) = "DOC2" Then
  49.                         Exit Do
  50.                     End If
  51.                     If UCase(rsDoc1Chk("ppmk_dock_compltd")) = "DOC1" Then
  52.                         rsDoc1Chk.Close
  53.                         rsdoc.Close
  54.                         rsVhclMake.Close
  55.                         GoTo skip_slno
  56.                         Exit Do
  57.                     End If
  58.                     rsDoc1Chk.MoveNext
  59.                 Loop
  60.                 rsDoc1Chk.Close
  61.             End If
  62.             rsdoc.MoveNext
  63.         Wend
  64.         rsdoc.Close
  65.         rsVhclMake.Close
  66.         Dim rsSMveh As New ADODB.Recordset
  67.         rsSMveh.Open ("SELECT ppmk_start_km_doc1 FROM preventive_prgm_maint_kms WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date = '" & maxdate & "'"), gcnn, adOpenDynamic, adLockOptimistic
  68.         If (rsSMveh("ppmk_start_km_doc1") > 13000 And VEHMAKE = "SM") Then
  69.             'strQuerySM = "UPDATE preventive_prgm_maint_kms SET PPMK_SLNO=" & Row_Var & " WHERE PPMK_VHCL_NO='" & Vhcl_no & "' and ppmk_date='" & maxdate & "'"
  70.             strQuerySM = "UPDATE preventive_prgm_maint_kms SET ppmk_slno = " & Row_Var & " WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date = '" & maxdate & "' AND ppmk_start_km_doc1 BETWEEN 13000 AND 20000 "
  71.             gcnn.Execute (strQuerySM)
  72.             GoTo rowincr
  73.         End If
  74.         StrQuery1 = "UPDATE preventive_prgm_maint_kms SET ppmk_slno = " & Row_Var & " WHERE ppmk_vhcl_no = '" & Vhcl_no & "' AND ppmk_date = '" & maxdate & "' AND ppmk_start_km_doc1 BETWEEN 18000 AND 25000 "
  75.         gcnn.Execute (StrQuery1)
  76. rowincr:
  77.         Row_Var = Row_Var + 1
  78.         rsSMveh.Close
  79. skip_slno:
  80.         rsSlno.MoveNext
  81.         rsRecordFind.Close
  82.     Wend
  83.     rsSlno.Close
  84.     Dim strQueryKmDesc As String
  85.     Dim rsKmSlno As New ADODB.Recordset
  86.     Dim vardesc, veh_slno As Integer
  87.     Dim veh_no As String
  88.     vardesc = 1
  89.     strQueryKmDesc = "SELECT * FROM preventive_prgm_maint_kms WHERE ppmk_slno IS NOT NULL ORDER BY ppmk_start_km_doc1 DESC"
  90.     rsKmSlno.Open (strQueryKmDesc), gcnn, adOpenDynamic, adLockOptimistic
  91.     While Not rsKmSlno.EOF
  92.         veh_no = rsKmSlno("ppmk_vhcl_no")
  93.         veh_slno = rsKmSlno("ppmk_slno")
  94.         gcnn.Execute ("UPDATE preventive_prgm_maint_kms SET ppmk_slno = " & vardesc & " WHERE ppmk_vhcl_no = '" & veh_no & "' AND ppmk_slno = '" & veh_slno & "'")
  95.         rsKmSlno.MoveNext
  96.         vardesc = vardesc + 1
  97.     Wend
  98.     rsKmSlno.Close
  99.     Load deVMS
  100.     With deVMS
  101.         If .rsCommand2_Grouping.State <> 0 Then .rsCommand2_Grouping.Close
  102.         '.Command2 CDate(sysd)
  103.     End With
  104.     DataReport2.Refresh
  105.     If DataReport2.Visible = False Then DataReport2.Show
  106.     strQuery2 = "UPDATE preventive_prgm_maint_kms SET ppmk_slno = ''"
  107.     gcnn.Execute (strQuery2)
  108.     Call ConnClose
  109.  
  110. End Sub
i am geeting error in line 23
Dec 12 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.