Full Version: Run time error
UtterAccess Forums > Microsoft® Access > Access Forms
EMILYTAN
Below are my code...
Couldn't understand how come there is run time error in this line...but the code can executed....
If myrecset!ST_SerialNumber = myrecset1!S_SerialNumber And myrecset!ST_ModelNo = myrecset1!PTO_Model Then
jwhite
Hi Emily,
Not enough info given to help you...
There is a RunTime Error on your line, but the code is still executed ?????
If the Module isn't too big, can you post it here so we can see what the rest of the code is?
EMILYTAN
Well I have this line and I found out why is there run time error because of the delete statement
CODE

If myrecset!ST_SerialNumber = myrecset1!S_SerialNumber And myrecset!ST_ModelNo = myrecset1!PTO_Model Then
                mySQL2 = "Update ShelfLifeQuery set OracleIncomingCheck = -1"
                mySQL2 = mySQL2 & " Where S_SerialNumber= '" & myrecset1!S_SerialNumber & "' AND PTO_Model ='" & myrecset1!PTO_Model & "'"
                CurrentDb.Execute mySQL2, dbFailOnError
                Debug.Print mySQL2
                
     --------------------------this line works well--------------------------------
                
                
                'strSQL3 = "Delete * From ShelflifeTransaction Where ShelflifeTransaction.ST_SerialNumber= '" & myrecset1!S_SerialNumber & "' And ST_ModelNo = '" & myrecset1!PTO_Model & "'"
                'CurrentDb.Execute strSQL3, dbFailOnError
-----------------------this line create run time error-------------------

The update statement will check box those match between 2 different table while the delete statement will delete the record after the record is being checked....
jwhite
Put the "Debug.Print..." line before the CurrentDb.Execute statements. Backup your data (if live data), unREM the DELETE block, run the process again that runs this code. After the failure, look in the VB Immediate Window to see what strSQL3 contains - and look for syntax errors or field errors (ie. comparing a number to a DataType=Text field).

Didn't understand the last line, don't know your business rules, so cannot evaluate in that regard.
EMILYTAN
I try to debug and print already but there is nothing wrong and just that it can only perform 1 at a time....
Below is the full code:-
CODE
  
mySQL = "SELECT ShelflifeTransaction.ST_SerialNumber, ST_ModelNo FROM ShelflifeTransaction "
myrecset.Open mySQL
If myrecset.BOF And myrecset.EOF Then
myrecset.Close
Exit Sub
Else
    
  
    
    Do Until myrecset.EOF
        
        
        mySQL1 = "SELECT ShelflifeQuery.S_SerialNumber, PTO_Model FROM ShelflifeQuery"
        
        myrecset1.Open mySQL1
        
      
        If myrecset1.BOF And myrecset1.EOF Then
            
            myrecset1.Close
            Exit Sub
        Else
            
            
            Do Until myrecset1.EOF
                
                
                If myrecset!ST_SerialNumber = myrecset1!S_SerialNumber And myrecset!ST_ModelNo = myrecset1!PTO_Model Then
                mySQL2 = "Update ShelfLifeQuery set OracleIncomingCheck = -1"
                mySQL2 = mySQL2 & " Where S_SerialNumber= '" & myrecset1!S_SerialNumber & "' AND PTO_Model ='" & myrecset1!PTO_Model & "'"
                Debug.Print mySQL2
                CurrentDb.Execute mySQL2, dbFailOnError
                
                
              
                
                
                strSQL3 = "Delete * From ShelflifeTransaction Where ShelflifeTransaction.ST_SerialNumber= '" & myrecset!ST_SerialNumber & "' And ST_ModelNo = '" & myrecset!ST_ModelNo & "'"
                
                 Debug.Print strSQL3
                CurrentDb.Execute strSQL3, dbFailOnError
              
                    
                End If
                myrecset1.MoveNext
            Loop
            myrecset1.Close
        End If
    myrecset.MoveNext
    Loop
    myrecset.Close
EMILYTAN
Hi,
Thanks for your reply...
I have get another alternative way of doing it already...
thanks
jwhite
Great! Good luck with the project! thumbup.gif
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.