Hello,
I am confused by why my code is not picking up the where criteria in a docmd.openform line. I have a form based on a select statement (join two tables, Transactions and DocRec, and then select the records where Transactions.PRC2 is null). This is done for dates between two values that the user specifies. This form is opened in datasheet view from another form, call it MonthReportPreparation_OTPS. On MonthReportPreparation_OTPS, the user types the reporting start date into a text box and hits buttons to view different forms and reports. All the forms open using docmd.openform- but they are all listing only one item in the Where Condition. When I try to use the same approach for this PRC2 form that requires more than one where condition, the parameters are not picked up by the code and a paramter entry box is displayed for me to type them in manually.
This is what I have for the on click event of the problematic button:
I tried putting the first two items in the where condition (the 'Transactions.PRC2DocID Is Null And DocRec.[Class Code]=100' parts) into the sql query itself, and leaving only the date criteria in this vb line, but that doesn't work either. All the field names exist and are spelled correctly.
Would anyone be able to tell me why docmd.openform works with a single where criteria but asks for parameters input with multiple criteria?
Thank you!
I am confused by why my code is not picking up the where criteria in a docmd.openform line. I have a form based on a select statement (join two tables, Transactions and DocRec, and then select the records where Transactions.PRC2 is null). This is done for dates between two values that the user specifies. This form is opened in datasheet view from another form, call it MonthReportPreparation_OTPS. On MonthReportPreparation_OTPS, the user types the reporting start date into a text box and hits buttons to view different forms and reports. All the forms open using docmd.openform- but they are all listing only one item in the Where Condition. When I try to use the same approach for this PRC2 form that requires more than one where condition, the parameters are not picked up by the code and a paramter entry box is displayed for me to type them in manually.
This is what I have for the on click event of the problematic button:
PHP:
DoCmd.OpenForm "Purchasing_PRC2_withoutInvoice_form", View:=acFormDS, wherecondition:="Transactions.PRC2DocID Is Null And DocRec.[Class Code]=100 and [Date of Record] between #" & Forms!MonthReportPreparation_OTPS.startdateparOTPS & "# and #" & EndOfMonth(Forms!MonthReportPreparation_OTPS.startdateparOTPS) & "#"
I tried putting the first two items in the where condition (the 'Transactions.PRC2DocID Is Null And DocRec.[Class Code]=100' parts) into the sql query itself, and leaving only the date criteria in this vb line, but that doesn't work either. All the field names exist and are spelled correctly.
Would anyone be able to tell me why docmd.openform works with a single where criteria but asks for parameters input with multiple criteria?
Thank you!