Form Code help

  • Thread starter Thread starter TotallyConfused
  • Start date Start date
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
 
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?
 
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)
 
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.
 
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)
 
Back
Top