Grrr - another productivity killer.
A5V5 Latest Version
I have a Modal Maintenance Form that is called from another Form - the below happens whether I open it from another form (or just run it off the Forms menu).
If I place this code in the OnInit event of the called Form:
topparent:Field1.value = ws_athleteid
t3=table.open("athletes")
t3.fetch_first()
query.filter = "At_id=var->ws_athleteid"
qry_meetings = t3.query_create()
nrecs=qry_meetings.records_get()
topparent:ws_athlete.value=t3.At_surname+t3.At_firstname
t3.close()
Then I get a "bad object handle" message and then the Form opens (with my athlete name loaded). If I comment out the Oninit code:
'topparent:Field1.value = ws_athleteid
't3=table.open("athletes")
't3.fetch_first()
'query.filter = "At_id=var->ws_athleteid"
'qry_meetings = t3.query_create()
'nrecs=qry_meetings.records_get()
'topparent:ws_athlete.value=t3.At_surname+t3.At_firstname
't3.close()
I get a "not an executable file" - but then opens my Form - go figure...
ws_athleteid is a global variable set in my calling Form. ws_athlete is a variable defined in the called Form using the A5 variable define facility in the Form/variable pop-down menu.
If I remove all code completly from the OnInit event then the Form opens fine from menu and from my calling Form.
Now here's the catch, I have another Form that I call from the same Form, I have the same Init event code and it works a treat - the only difference being that I open the called Form in new record mode (this.new_record()).
this.new_record()
topparent:Field1.value = ws_athleteid
t3=table.open("athletes")
t3.fetch_first()
query.filter = "At_id=var->ws_athleteid"
qry_meetings = t3.query_create()
nrecs=qry_meetings.records_get()
topparent:ws_athlete.value=t3.At_surname+t3.At_firstname
t3.close()
Both called Forms are Modal, both called Forms maintain the same data (in fact one Form was duplicated form the other).
A5 offers no useful error info - nor does debug help solve the issue. Is it a problem with my code or an A5 issue? Has anyone come across the same issue - and found a solution..
I have noticed prior postings regarding similar errors - but I find the above inexplicable..
Regards,
Scott
Ps
Here's the code that decides which Form to call:
DIM GLOBAL ws_athleteid AS n
DIM nrecs as n
DIM Shared varP_Mnt_athleteprofilenew as P
DIM Shared varP_Mnt_athleteprofile as P
DIM layout_name as c
'Get 'Value' property of 'Athleteid' in Form 'mnt_athletes' .
DIM GLOBAL ws_athleteid AS n
ws_athleteid = topparent:Athleteid.value
t3=table.open("athleteprofile")
t3.fetch_first()
query.filter = "Ap_athleteid=var->ws_athleteid"
qry_meetings = t3.query_create()
nrecs=qry_meetings.records_get()
t3.close()
If nrecs=0 then
layout_name = "Mnt_athleteprofilenew"
varP_Mnt_athleteprofilenew = :Form.view(layout_name,"dialog")
if is_object(varP_Mnt_athleteprofilenew) = .t. then
varP_Mnt_athleteprofilenew.close()
end if
end if
If nrecs>0 then
layout_name = "Mnt_athleteprofile"
varP_Mnt_athleteprofile = :Form.view(layout_name,"dialog")
if is_object(varP_Mnt_athleteprofile) = .t. then varP_Mnt_athleteprofile.close()
end if
end if
A5V5 Latest Version
I have a Modal Maintenance Form that is called from another Form - the below happens whether I open it from another form (or just run it off the Forms menu).
If I place this code in the OnInit event of the called Form:
topparent:Field1.value = ws_athleteid
t3=table.open("athletes")
t3.fetch_first()
query.filter = "At_id=var->ws_athleteid"
qry_meetings = t3.query_create()
nrecs=qry_meetings.records_get()
topparent:ws_athlete.value=t3.At_surname+t3.At_firstname
t3.close()
Then I get a "bad object handle" message and then the Form opens (with my athlete name loaded). If I comment out the Oninit code:
'topparent:Field1.value = ws_athleteid
't3=table.open("athletes")
't3.fetch_first()
'query.filter = "At_id=var->ws_athleteid"
'qry_meetings = t3.query_create()
'nrecs=qry_meetings.records_get()
'topparent:ws_athlete.value=t3.At_surname+t3.At_firstname
't3.close()
I get a "not an executable file" - but then opens my Form - go figure...
ws_athleteid is a global variable set in my calling Form. ws_athlete is a variable defined in the called Form using the A5 variable define facility in the Form/variable pop-down menu.
If I remove all code completly from the OnInit event then the Form opens fine from menu and from my calling Form.
Now here's the catch, I have another Form that I call from the same Form, I have the same Init event code and it works a treat - the only difference being that I open the called Form in new record mode (this.new_record()).
this.new_record()
topparent:Field1.value = ws_athleteid
t3=table.open("athletes")
t3.fetch_first()
query.filter = "At_id=var->ws_athleteid"
qry_meetings = t3.query_create()
nrecs=qry_meetings.records_get()
topparent:ws_athlete.value=t3.At_surname+t3.At_firstname
t3.close()
Both called Forms are Modal, both called Forms maintain the same data (in fact one Form was duplicated form the other).
A5 offers no useful error info - nor does debug help solve the issue. Is it a problem with my code or an A5 issue? Has anyone come across the same issue - and found a solution..
I have noticed prior postings regarding similar errors - but I find the above inexplicable..
Regards,
Scott
Ps
Here's the code that decides which Form to call:
DIM GLOBAL ws_athleteid AS n
DIM nrecs as n
DIM Shared varP_Mnt_athleteprofilenew as P
DIM Shared varP_Mnt_athleteprofile as P
DIM layout_name as c
'Get 'Value' property of 'Athleteid' in Form 'mnt_athletes' .
DIM GLOBAL ws_athleteid AS n
ws_athleteid = topparent:Athleteid.value
t3=table.open("athleteprofile")
t3.fetch_first()
query.filter = "Ap_athleteid=var->ws_athleteid"
qry_meetings = t3.query_create()
nrecs=qry_meetings.records_get()
t3.close()
If nrecs=0 then
layout_name = "Mnt_athleteprofilenew"
varP_Mnt_athleteprofilenew = :Form.view(layout_name,"dialog")
if is_object(varP_Mnt_athleteprofilenew) = .t. then
varP_Mnt_athleteprofilenew.close()
end if
end if
If nrecs>0 then
layout_name = "Mnt_athleteprofile"
varP_Mnt_athleteprofile = :Form.view(layout_name,"dialog")
if is_object(varP_Mnt_athleteprofile) = .t. then varP_Mnt_athleteprofile.close()
end if
end if
Comment