March 10, 200520 yr Author I have a script that is used to import a record from one database to another(Database 1, Database 2). The script will first check to see if the record already exist in Database 2. If it does then it increases the number in a number field by 1. If it doesn't exist in Database 2 it imports the record from Database 1 to Database 2. The script I have now copies an ID # from Database 1. Then goes to Database 2, goes into find mode, paste the ID# in the ID field, and performs a find. If the Total record count > 0 it increases the number in a number field by 1. The problem I'm running into is, if there are no records found I need to import the file in from Database 1. But the script keeps ending after it doesn't find any records. Even if I click on continue. Any help you can give is much appreciated.
March 10, 200520 yr I have a script that is used to import a record from one database to another(Database 1, Database 2). The script will first check to see if the record already exist in Database 2. If it does then it increases the number in a number field by 1. If it doesn't exist in Database 2 it imports the record from Database 1 to Database 2. The script I have now copies an ID # from Database 1. Then goes to Database 2, goes into find mode, paste the ID# in the ID field, and performs a find. If the Total record count > 0 it increases the number in a number field by 1. The problem I'm running into is, if there are no records found I need to import the file in from Database 1. But the script keeps ending after it doesn't find any records. Even if I click on continue. Any help you can give is much appreciated.
March 10, 200520 yr Author I have a script that is used to import a record from one database to another(Database 1, Database 2). The script will first check to see if the record already exist in Database 2. If it does then it increases the number in a number field by 1. If it doesn't exist in Database 2 it imports the record from Database 1 to Database 2. The script I have now copies an ID # from Database 1. Then goes to Database 2, goes into find mode, paste the ID# in the ID field, and performs a find. If the Total record count > 0 it increases the number in a number field by 1. The problem I'm running into is, if there are no records found I need to import the file in from Database 1. But the script keeps ending after it doesn't find any records. Even if I click on continue. Any help you can give is much appreciated.
March 10, 200520 yr Not sure what version you are running, but in general you use the following logic: Set Error Capture (ON) // Lets you trap that irritating error message Enter Find Mode ...Field Logic... Perform Find // 401 = No Records Found. FM Help has all the Error Codes if (Status (CurrentError) = 401) ... Do your alternate logic here else ... Do your normal logic here endif
March 10, 200520 yr Not sure what version you are running, but in general you use the following logic: Set Error Capture (ON) // Lets you trap that irritating error message Enter Find Mode ...Field Logic... Perform Find // 401 = No Records Found. FM Help has all the Error Codes if (Status (CurrentError) = 401) ... Do your alternate logic here else ... Do your normal logic here endif
March 10, 200520 yr Not sure what version you are running, but in general you use the following logic: Set Error Capture (ON) // Lets you trap that irritating error message Enter Find Mode ...Field Logic... Perform Find // 401 = No Records Found. FM Help has all the Error Codes if (Status (CurrentError) = 401) ... Do your alternate logic here else ... Do your normal logic here endif
March 10, 200520 yr Rather than mess with error codes, and have to try remembering them, I use STATUS(CurrentFoundCount)= 0 then my Find turned up nothing. Steve
March 10, 200520 yr Rather than mess with error codes, and have to try remembering them, I use STATUS(CurrentFoundCount)= 0 then my Find turned up nothing. Steve
March 10, 200520 yr Rather than mess with error codes, and have to try remembering them, I use STATUS(CurrentFoundCount)= 0 then my Find turned up nothing. Steve
March 10, 200520 yr Agreed Steve. Since Heathbo is using vs. 7, it would be: If [ not Get(FoundCount) ] ... which is same as If [ Get(FoundCount) = 0 ] ... ... do whatever you wish when no records found ... Else ... do whatever with found set ... End If I didn't want him to waste his time hunting for the ole Status() functions. Lord am I glad they are gone! Get() is more accurate, appropriate, and easier to write.
March 10, 200520 yr Agreed Steve. Since Heathbo is using vs. 7, it would be: If [ not Get(FoundCount) ] ... which is same as If [ Get(FoundCount) = 0 ] ... ... do whatever you wish when no records found ... Else ... do whatever with found set ... End If I didn't want him to waste his time hunting for the ole Status() functions. Lord am I glad they are gone! Get() is more accurate, appropriate, and easier to write.
March 10, 200520 yr Agreed Steve. Since Heathbo is using vs. 7, it would be: If [ not Get(FoundCount) ] ... which is same as If [ Get(FoundCount) = 0 ] ... ... do whatever you wish when no records found ... Else ... do whatever with found set ... End If I didn't want him to waste his time hunting for the ole Status() functions. Lord am I glad they are gone! Get() is more accurate, appropriate, and easier to write.
March 10, 200520 yr FYI: In FM7, when no records are found, it goes back to the previous found set. So Get(FoundCount) would not work. Better to use Get(LastError)=401. But I'm not sure Heathbo's algorithm is the best. I'd probably try something that uses a relationship between the two databases to search for those records in database 1 that have no matching records in database 2, then import the whole lot at once. For incrementing the existing records, do a similar find in database 1 for those records that do have a matching record in database 2, loop through them once, incrementing the counter in the related record in database 2.
March 10, 200520 yr FYI: In FM7, when no records are found, it goes back to the previous found set. So Get(FoundCount) would not work. Better to use Get(LastError)=401. But I'm not sure Heathbo's algorithm is the best. I'd probably try something that uses a relationship between the two databases to search for those records in database 1 that have no matching records in database 2, then import the whole lot at once. For incrementing the existing records, do a similar find in database 1 for those records that do have a matching record in database 2, loop through them once, incrementing the counter in the related record in database 2.
March 10, 200520 yr FYI: In FM7, when no records are found, it goes back to the previous found set. So Get(FoundCount) would not work. Better to use Get(LastError)=401. But I'm not sure Heathbo's algorithm is the best. I'd probably try something that uses a relationship between the two databases to search for those records in database 1 that have no matching records in database 2, then import the whole lot at once. For incrementing the existing records, do a similar find in database 1 for those records that do have a matching record in database 2, loop through them once, incrementing the counter in the related record in database 2.
Create an account or sign in to comment