Home

Macros and Programming

 

CardboxForumsMacros and Programming > "loop problems"

loop problems

the macro loop for two linked databases will stop, when a keyword is missing

Current user: [none]
Register / Log In · Help

Posted By Post

herman.cbx

21-Jun-2017 07:26

Two databases ("Nederland.fil" and "Alpen.fil") linked by Relational will stop when I use a macro loop if a keyword of one of the databases is missing or misspelled. Sometimes I want to copy a field from one database to the other. For that purpose I use a loop, but when a keyword is missing the loop stops and a message appears. In that case that record should be skipped and proceed with the next one. See example below.
Is that possible?

for i = 1 to 1500
EditRecord
GoToField "STANDAARDLIJST"
Activate "Nederland"
EditRecord
Command cmdEnd+cmdShift
Command cmdCopy
GoToField "SL"
TypeText "x"
SaveRecord
Activate "Alpen"
Command cmdPaste
SaveRecord
NextRecord
sleep 50
next

bert

21-Jun-2017 09:27

Perhaps is then a statement in first line of your macro as:
on error resume next

for you a simple solution in this case.

However, If understand this well macro runs in a situation of a relational search.
I hope this will work in every case and hope you have no trouble with 's Gravenhage and/or Driebergen-Rijsenburg...
I think your error will be raised because the edit command cannot run: there are no records to edit in some situations?
(please add always errormessages!!)

Then it is also an option to check first before an edit command if there is a record to edit.

Before EditRecord you need this:
If Records.Count > 0 then
...do things...

Then after SaveRecord :
End if

However, you need the line 1+2 to move to the line direct after Activate "Alpen".
Regards
Bert

herman.cbx

21-Jun-2017 13:21

Thank you very much, Bert. This will do!

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home