Form OnDelete Event Problem...

S

Sharkbyte

I have 2 unbound subforms I am working with. When entries are added to the
first, I run code ending with a Requery of the second.

I am trying to do the same thing for when a record is removed. Using the
form's OnDelete event I am able to execute code; however, even though I
again end with a Requery of the second form, the results suggest that the
Requery doesn't actually fire.

Here is the code I am running:


If IsNull(DLookup("uskillsetid", "qryjobcosting6")) Then
DoCmd.SetWarnings False
DoCmd.RunSQL ("update dbo_tbltechnicianskillsets set _
calculatedrate = 0 where skillsetid = [Forms]! _

[frmtechnicianskillsets]![subfrmTechnicianSkillsets]![txtskillsetid];")
DoCmd.SetWarnings True

[Forms]![frmtechnicianskillsets]![subfrmTechnicianSkillsets1].Requery

Exit Function
Else
End If

Could the Requery be firing before the DoCmd? I have not been able to
determine that any other event is firing after the OnDelete, where I might be
able to trigger the Requery.

* I have also attempted to identify the subform as: [formname].Form.Requery
but Access says it's not supported.

All help is appreciated.

Thanks.

Sharkbyte
 
C

Cheese_whiz

Hi Sharkbyte,

Try:

[Forms]![frmtechnicianskillsets]![subfrmTechnicianSkillsets1].Form.Requery

Notice the '.Form'

I could be offbase...

HTH,
CW
 
S

Sharkbyte

CW: Thanks for the try. But you missed this in my last post...
* I have also attempted to identify the subform as: [formname].Form.Requery
but Access says it's not supported.

Ultimately, I just found a work-around. I switched to using the DoubleClick
event, and ran code to delete the row. As I continued trying things, Access
kept hanging acting like it hadn't completed the OnDelete event, but I could
find no way to finish it. This way after the DoubleClick event begins,
everything happens in code, and the form isn't expected to do anything.
Works perfect. :D

Thanks.

Sharkbyte



Cheese_whiz said:
Hi Sharkbyte,

Try:

[Forms]![frmtechnicianskillsets]![subfrmTechnicianSkillsets1].Form.Requery

Notice the '.Form'

I could be offbase...

HTH,
CW

Sharkbyte said:
I have 2 unbound subforms I am working with. When entries are added to the
first, I run code ending with a Requery of the second.

I am trying to do the same thing for when a record is removed. Using the
form's OnDelete event I am able to execute code; however, even though I
again end with a Requery of the second form, the results suggest that the
Requery doesn't actually fire.

Here is the code I am running:


If IsNull(DLookup("uskillsetid", "qryjobcosting6")) Then
DoCmd.SetWarnings False
DoCmd.RunSQL ("update dbo_tbltechnicianskillsets set _
calculatedrate = 0 where skillsetid = [Forms]! _

[frmtechnicianskillsets]![subfrmTechnicianSkillsets]![txtskillsetid];")
DoCmd.SetWarnings True

[Forms]![frmtechnicianskillsets]![subfrmTechnicianSkillsets1].Requery

Exit Function
Else
End If

Could the Requery be firing before the DoCmd? I have not been able to
determine that any other event is firing after the OnDelete, where I might be
able to trigger the Requery.

* I have also attempted to identify the subform as: [formname].Form.Requery
but Access says it's not supported.

All help is appreciated.

Thanks.

Sharkbyte
 
C

Cheese_whiz

Hi Shark,

Glad you found a solution.

I am, though, fairly certain that
Forms!FormName!subFrmControlName.Form.Requery is perfrectly acceptable. My
real question was about the impact of your unbound form situation since I
mostly use bound forms.

CW

Sharkbyte said:
CW: Thanks for the try. But you missed this in my last post...
* I have also attempted to identify the subform as: [formname].Form.Requery
but Access says it's not supported.

Ultimately, I just found a work-around. I switched to using the DoubleClick
event, and ran code to delete the row. As I continued trying things, Access
kept hanging acting like it hadn't completed the OnDelete event, but I could
find no way to finish it. This way after the DoubleClick event begins,
everything happens in code, and the form isn't expected to do anything.
Works perfect. :D

Thanks.

Sharkbyte



Cheese_whiz said:
Hi Sharkbyte,

Try:

[Forms]![frmtechnicianskillsets]![subfrmTechnicianSkillsets1].Form.Requery

Notice the '.Form'

I could be offbase...

HTH,
CW

Sharkbyte said:
I have 2 unbound subforms I am working with. When entries are added to the
first, I run code ending with a Requery of the second.

I am trying to do the same thing for when a record is removed. Using the
form's OnDelete event I am able to execute code; however, even though I
again end with a Requery of the second form, the results suggest that the
Requery doesn't actually fire.

Here is the code I am running:


If IsNull(DLookup("uskillsetid", "qryjobcosting6")) Then
DoCmd.SetWarnings False
DoCmd.RunSQL ("update dbo_tbltechnicianskillsets set _
calculatedrate = 0 where skillsetid = [Forms]! _

[frmtechnicianskillsets]![subfrmTechnicianSkillsets]![txtskillsetid];")
DoCmd.SetWarnings True

[Forms]![frmtechnicianskillsets]![subfrmTechnicianSkillsets1].Requery

Exit Function
Else
End If

Could the Requery be firing before the DoCmd? I have not been able to
determine that any other event is firing after the OnDelete, where I might be
able to trigger the Requery.

* I have also attempted to identify the subform as: [formname].Form.Requery
but Access says it's not supported.

All help is appreciated.

Thanks.

Sharkbyte
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top