manish prasher
New Member
i have an ongoing error in ms access vba, being pretty new to the app i am stuck, i have a split database where in i am trying to execute a query in vba but it is throwing the error"No values found for one or more given parameter" however when i debug.print the query and run in ms access it works fine,
below is the query, can you help:
qry = "SELECT * FROM Core"
qry1 = qry & " WHERE (((Core.Activity='" & UCase([Forms]![frmReports]![cmbrptactivity]) & "') AND (Core.Unit='" & UCase([Forms]![frmReports]![cmbunit]) & "') AND (Core.Dt_Upload Between #" & [Forms]![frmReports]![txtDate1] & "# And #" & [Forms]![frmReports]![txtDate2] & "#)))"
qry2 = qry1 & " OR (((Core.Activity='" & UCase([Forms]![frmReports]![cmbrptactivity]) & "') AND (([Forms]![frmreports]![cmbunit]) Is Null) AND (Core.Dt_Upload Between #" & [Forms]![frmReports]![txtDate1] & "# And #" & [Forms]![frmReports]![txtDate2] & "#)))"
qry3 = qry2 & " OR ((((Core.Unit)='" & UCase([Forms]![frmReports]![cmbunit]) & "') AND (([Forms]![frmreports]![cmbrptactivity]) Is Null) AND ((Core.Dt_Upload) Between (#" & [Forms]![frmReports]![txtDate1] & "#) And (#" & [Forms]![frmReports]![txtDate2] & "#))))"
qry4 = qry3 & " OR (((([Forms]![frmreports]![cmbunit]) Is Null) AND (([Forms]![frmreports]![cmbrptactivity]) Is Null) AND ((Core.Dt_Upload) Between (#" & [Forms]![frmReports]![txtDate1] & "#) And (#" & [Forms]![frmReports]![txtDate2] & "#))))"
rs.Open qry4, cn, adOpenKeyset, adLockOptimistic
below is the query, can you help:
qry = "SELECT * FROM Core"
qry1 = qry & " WHERE (((Core.Activity='" & UCase([Forms]![frmReports]![cmbrptactivity]) & "') AND (Core.Unit='" & UCase([Forms]![frmReports]![cmbunit]) & "') AND (Core.Dt_Upload Between #" & [Forms]![frmReports]![txtDate1] & "# And #" & [Forms]![frmReports]![txtDate2] & "#)))"
qry2 = qry1 & " OR (((Core.Activity='" & UCase([Forms]![frmReports]![cmbrptactivity]) & "') AND (([Forms]![frmreports]![cmbunit]) Is Null) AND (Core.Dt_Upload Between #" & [Forms]![frmReports]![txtDate1] & "# And #" & [Forms]![frmReports]![txtDate2] & "#)))"
qry3 = qry2 & " OR ((((Core.Unit)='" & UCase([Forms]![frmReports]![cmbunit]) & "') AND (([Forms]![frmreports]![cmbrptactivity]) Is Null) AND ((Core.Dt_Upload) Between (#" & [Forms]![frmReports]![txtDate1] & "#) And (#" & [Forms]![frmReports]![txtDate2] & "#))))"
qry4 = qry3 & " OR (((([Forms]![frmreports]![cmbunit]) Is Null) AND (([Forms]![frmreports]![cmbrptactivity]) Is Null) AND ((Core.Dt_Upload) Between (#" & [Forms]![frmReports]![txtDate1] & "#) And (#" & [Forms]![frmReports]![txtDate2] & "#))))"
rs.Open qry4, cn, adOpenKeyset, adLockOptimistic