Query not working (1 Viewer)

atrium

Registered User.
Local time
Today, 09:19
Joined
May 13, 2014
Messages
348
I'm sure it has something to do with the address of the criteria.
I have a form with a subform and and within that subform I perform the following

Code:
 Me.PaymentFeeFld = DLookup("PaymentFee", "DdSchedules", "[DdSchedId] = " & DdSchedId)
  MsgBox "The PaymentFee = " & Me.PaymentFeeFld & " The Schedule Id = " & DdSchedId
  If Me.TotOwedFld <= 0 Then
     MsgBox "The Total Owed Amount is <= to zero " & vbCrLf & "The system will change the status to Completed. Change the Include Checked box to Off." & vbCrLf & "No other payments will be attempted on this schedule"
     DoCmd.SetWarnings False
     DoCmd.OpenQuery "UpdateDDSchedCompletedQry"                    '--- Change the schedule status to Completed.
     DoCmd.SetWarnings True

The SQL for the query "UpdateDDSchedCompletedQry is

UPDATE DdSchedules SET DdSchedules.Status = "Completed"
WHERE (((DdSchedules.DdSchedId)=[Forms]![DdCreateABAFileFrm]![DdPaymtTransDueSubform].[Form].[DdSchedId]));

Each time I run this query it asks me to enter the DdSchedId
DdCreateABAFileFrm - is the Parent form
DdPaymtTransDueSubform - is the child subform

Even if I put in the value of DdSchedId into the query it doesn't work. It displays the field with the old contents

Any help would be appreciated
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:19
Joined
May 7, 2009
Messages
19,245
you can try replacing your DoCmd.OpenQuery "updateDDSchedCompletedQry" with
DoCmd.RunSQL:

dim SQL As String
SQL = "UPDATE DdSchedules SET DdSchedules.Status = 'Completed' " & _
"WHERE DdSchedules.DdSchedId = " & [DdSchedId]

DoCmd.RunSQL SQL
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:19
Joined
Sep 21, 2011
Messages
14,317
Is DdPaymtTransDueSubform also the subform control name?
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 19:19
Joined
Jan 23, 2006
Messages
15,379
Since it is repeatedly asking for a value for DdSchedId, it seems Access is confused as to the location of it. Do you have a test database with only a few records - enough to highlight the issue- that you can post?
 

Users who are viewing this thread

Top Bottom