Form Code help

T

TotallyConfused

Hi can someone please help with this? Trying to understand why this is not
running? I have one other control on my form with the same code and it runs
just fine. When I make a change on the form it will ask for a parameter and
then debugs with the following highlighted. Thank you for any help you can
provide.

DoCmd.RunSQL "UPDATE [Tracking] SET [Tracking].[Contactperson] = '" & _
Forms![frm Provider Tracking].[Contactperson] & "' WHERE
([Tracking].[ID])= " & _
Forms![frmPRTrckg].[ID]




Private Sub Contactperson_AfterUpdate()
If MsgBox("Propagate Contactperson change?", vbYesNo) = vbYes Then
'MsgBox ("yes: " & "UPDATE [Tracking] SET
[Tracking].[Contactperson] = '" & _
Me.PRVDR_PH & "' WHERE ([Tracking].[ID])= " & Me.PRVDR_ID)
'run a query to update
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE [Tracking] SET [Tracking].[Contactperson] = '"
& _
Forms![frm Provider Tracking].[Contactperson] & "' WHERE
([Tracking].[ID])= " & _
Forms![frmPRTrckg].[ID]
DoCmd.SetWarnings True

Else
'do nothing
End If

End Sub
 
D

Dirk Goldgar

TotallyConfused said:
Hi can someone please help with this? Trying to understand why this is
not
running? I have one other control on my form with the same code and it
runs
just fine. When I make a change on the form it will ask for a parameter
and
then debugs with the following highlighted. Thank you for any help you
can
provide.

DoCmd.RunSQL "UPDATE [Tracking] SET [Tracking].[Contactperson] = '" & _
Forms![frm Provider Tracking].[Contactperson] & "' WHERE
([Tracking].[ID])= " & _
Forms![frmPRTrckg].[ID]



Are "frm Provider Tracking" and "frmPRTrckg" supposed to be the same form?
If so, one of those names is wrong.

What parameter does it ask you for?
 
T

TotallyConfused

Thank you. Yes the forms name should be the same - fixed that. But it is
still prompting me for Contactperson. What is wrong?

Dirk Goldgar said:
TotallyConfused said:
Hi can someone please help with this? Trying to understand why this is
not
running? I have one other control on my form with the same code and it
runs
just fine. When I make a change on the form it will ask for a parameter
and
then debugs with the following highlighted. Thank you for any help you
can
provide.

DoCmd.RunSQL "UPDATE [Tracking] SET [Tracking].[Contactperson] = '" & _
Forms![frm Provider Tracking].[Contactperson] & "' WHERE
([Tracking].[ID])= " & _
Forms![frmPRTrckg].[ID]



Are "frm Provider Tracking" and "frmPRTrckg" supposed to be the same form?
If so, one of those names is wrong.

What parameter does it ask you for?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

TotallyConfused said:
Thank you. Yes the forms name should be the same - fixed that. But it is
still prompting me for Contactperson. What is wrong? [...]
DoCmd.RunSQL "UPDATE [Tracking] SET [Tracking].[Contactperson] = '" & _
Forms![frm Provider Tracking].[Contactperson] & "' WHERE
([Tracking].[ID])= " & _
Forms![frmPRTrckg].[ID]

Check to make sure that "Contactperson" is actually the name of the field in
the Tracking table, and is spelled correctly.
 
T

TotallyConfused

Thank you very much for your help. The contactperson was misspelled. Thank
you

Dirk Goldgar said:
TotallyConfused said:
Thank you. Yes the forms name should be the same - fixed that. But it is
still prompting me for Contactperson. What is wrong? [...]
DoCmd.RunSQL "UPDATE [Tracking] SET [Tracking].[Contactperson] = '" & _
Forms![frm Provider Tracking].[Contactperson] & "' WHERE
([Tracking].[ID])= " & _
Forms![frmPRTrckg].[ID]

Check to make sure that "Contactperson" is actually the name of the field in
the Tracking table, and is spelled correctly.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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