Message alert is duplicated

Following and IF statement I have a message statement. When running the procedure, the message alert is produced twice…no clue why.

The message only appears once when I test-run procedure directly from procedure window but twice when the procedure is run from database

The above screenshot is not showing anything helpful for diagnostics or advice. Let us know the code that is producing that behavior.

if «Recipe Ingredient» contains “Y”
message “Updating Recipe Cost”
nickname=«Recipe Nickname»
newcost=«Unit Cost»
openfile “Recipe Ingredients.pandb”
find «Name in Recipe» contains nickname
«Unit Cost»=newcost
openfile “Recipe Costs”
farcall “Recipe Costs”,“New Update Procedure”
endif

When posting a question here, please keep in mind that no one else can see what it going on on your screen. You have to be our eyes and ears. We can only give help based on the information you provide.

Kurt suggested that you post the code involved, which would have been my suggestion also. However, you then posted code which clearly is not the code involved, or at least the entire code. since the code you posted does not contain the text *** PRICE INCREASE ***. Where is that code? Maybe in the New Update Procedure?

Also, you mention that the problem occurs only when you “run from database”. What does that mean? Is it run from the action menu? Is it being triggered automatically from an .Initialize procedure. Without all of the information, no one will be able to help you.

Oops! Sorry about that…my bad. The code is triggered automatically from data input. There is no similar code in New Update Procedure. I feel a little bit intimidated here as my skills are FAR from those of many others who post here but I appreciate the help. Here is the complete code for the procedure…local lstrcvd,lstvendor,lstcases,lstcasecost,lstunits,lstunitcost,lstdescription,product
global unitcost,nickname,newcost

product=Product
field “Date Received”
SortUp
selectall
select Product contains product
lastrecord
uprecord

lstrcvd=«Date Received»
lstvendor=Vendor
lstcases=«Cases Received»
lstcasecost=«Case Cost»
lstunits=«Units Per Case»
lstunitcost=«Unit Cost»
lstdescription=«Case Description»

lastrecord
lastrcvd=lstrcvd
lastvendor=lstvendor
lastcases=lstcases
lastcasecost=lstcasecost
lastunits=lstunits
lastunitcost=lstunitcost
lastdescription=lstdescription
«Case Description»=lastdescription
«Units Per Case»=lastunits

if «Case Cost»>lastcasecost
message “***PRICE INCREASE!***”
endif
if «Recipe Ingredient» contains “Y”
message “Updating Recipe Cost”
nickname=«Recipe Nickname»
newcost=«Unit Cost»
openfile “Recipe Ingredients.pandb”
find «Name in Recipe» contains nickname
«Unit Cost»=newcost
openfile “Recipe Costs”
farcall “Recipe Costs”,“New Update Procedure”
endif
openfile “Inventory File.pandb”
selectall
lastrecord

What does that mean exactly? Is this code in a named procedure? Is it in the code associated with a field? or called from a field? Or maybe it is in the code for a Text Editor object?

I don’t immediately see any reason why the message should appear twice. It may be possible that the code in New Update Procedure is somehow calling back to this code, we don’t have enough information to tell. However, if that was the case I would expect it to appear twice if triggered from the procedure as well.

If this was my database I would work on the problem by trying to break it down into smaller problems. I would start by putting code like this at the top of the procedure:

message "triggered" return

It doesn’t matter what the message actually says, anything will do. Then try data entry and see if the message appears twice. If it does, it is somehow being triggered twice and we would need to figure out why. If it only appears once, then something in the code below (including any code called by this, or code in .Initialize procedures in “Recipe Costs” or “Inventory File”) is causing the problem. In that case I would gradually move the message "triggered" return line down until the message appears twice. Then we’ll know where the problem is occurring.

Another question – is this old code that used to work but doesn’t any more? Or is it something brand new that has always had this issue?

‘Code is triggered automatically from input’ means data is entered into field and when Enter is pressed, the procedure begins. Yes, it is in a named procedure, not in Text Object. But now I’m very confused! I inserted your suggested message “Triggered” at the top of the procedure and then worked it down each line of code, anticipating the message duplication. That never happened. I then removed that message and simply ran New Update Procedure from the form. It worked perfectly! I might add, I did NOTHING to the procedure other than insert the Triggered message and then remove it! I will run it a few more times to make sure I’m not ‘seeing things’ and let you know. This is SOO strange! Thanks, Jim. You have always been helpful throughout the time since I first started using OverVue.