Apparent error wizard error

I get this error wizard message when I open a database:
“Field mDate is not visible in current record”.

This is the wizard display:

Screen Shot 2023-03-03 at 11.19.30 am

How can Panorama X select mDate > 0 but not see the field a few statements later?

Any chance field “mDate” is hidden? That would seem to be a situation that could give this result.

Not hidden.

Bill’s idea would be the same as mine. That would definitely do it.

Since you say that mDate is not hidden, I’m going to suggest that you remove the save statement. I don’t think you should ever use that in an .Initialization procedure. Also, I think anytime you use the save statement it should be the last statement in the procedure that references the database.

Also, I am wondering what the purpose of the first field statement is. Since it is immediately followed by another field statement, the first field statement doesn’t do anything. However, I suspect if you remove the first field statement, you’ll simply get an error on the second field statement, because of the save statement.

I’ve removed the save statement and I’ll see what happens in subsequent start-ups - the file opens at boot-up and the error is not reproducible with a manual opening of the file. I recall similar problems with the save statement in the past - it’s clearly not as simple a process as it looks.

There is logic behind the consecutive field statements. I want to display the date but, if I just select the Systolic field, the mDate field disappears off to the left of the screen. Selecting the two field leaves the Systolic field active and the mDate field visible.

Seems to me like you might want to consider changing the order of the fields in the data sheet, but I imagine you have some reason for not doing that.

I do indeed have a good reason for the order. One extra statement is not really a big overhead :slight_smile:

I simplified the procedure to this:

try
    select mDate > 0
    removeunselected
    lastrecord
    field mDate
catch
    message ".Initialize failed."
endcatch

field Systolic
save

and every time the Mac started I got the “Initialize failed” message. Inserting:

setactivedatabase "BP readings 30 days"

(where “BP readings 30 days” is the name of the file) at the beginning of the procedure solved that problem. No other Panorama X files are opened at start-up. I’m baffled but it’s not really important.

The above code (including the setactivedatabase statement) has gone back to failing often but not always. Very strange.

If you have this in a .Initialize routine, it seems like it might be a timing problem.

Have you tried adding some programmable delay before your Setactive … just to try it out?