B
BlueWolverine
Hello,
MS Access 2003 on XP Pro
I am trying to write some error message for my user. Basically, I have a
search panel for the user to use, and if the search yields zero records,
rather than the form coming up with no results, I'd rather a mesage box pop
up and say "No Records".
So the way I thought I'd do this is if the query that feeds than form has an
empty recordset, I would pop a message box. Well, here's the code I used for
this and then here's the message. (Error Message pops on code surrounded
like <<<THIS>>>.)
Dim myDB As Database, rs As Recordset, tqn As String
Set myDB = CurrentDb
tqn = "q_search_exact"
<<<Set rs = myDB.OpenRecordset(tqn)>>>
If rs.EOF Or rs.BOF Then
DoCmd.Beep
MsgBox "Returned zero (0) results.", vbOKOnly, "Search Complete"
Else
DoCmd.OpenForm "f_search_exact", acNormal
End If
Here's the error message.
Error 3061 too few parameters. Expected 12.
The query is stored in Access. (Written in SQL but stored, so not generated
in VBA, but written as a query.) Here is the SQL for the query.
SELECT q_FA_DOW.DayOfWeek, q_FA_DOW.Fleet_Activity, q_FA_DOW.BinstoOther,
q_FA_DOW.[CCC's], q_FA_DOW.VFG, q_FA_DOW.VRT, q_FA_DOW.[GQRS CAT],
q_FA_DOW.ACTION, q_FA_DOW.[Work Element Description], q_FA_DOW.Frequency,
q_FA_DOW.[WES#], q_FA_DOW.Source, q_FA_DOW.ID, q_FA_DOW.Active
FROM q_FA_DOW
WHERE (((q_FA_DOW.Fleet_Activity)=Forms!f_SearchPanel!FASearch Or
isnull(Forms!f_SearchPanel!FASearch)) And
((q_FA_DOW.VRT)=Forms!f_SearchPanel!VRTSearch Or
isnull(Forms!f_SearchPanel!VRTSearch)) And
((q_FA_DOW.VFG)=Forms!f_SearchPanel!VFGSearch Or
isnull(Forms!f_SearchPanel!VFGSearch)) And
((q_FA_DOW.[CCC's])=Forms!f_SearchPanel!CCCSearch Or
isnull(Forms!f_SearchPanel!CCCSearch)) And
((q_FA_DOW.Action)=Forms!f_SearchPanel!ActionSearch Or
isnull(Forms!f_SearchPanel!ActionSearch)) And ((q_FA_DOW.[GQRS
CAT])=Forms!f_SearchPanel!GQRS Or isnull(Forms!f_SearchPanel!GQRS)) And
((q_FA_DOW.[Work Element Description]) Like "*" & Forms!f_SearchPanel!WED1 &
"*" Or isnull(Forms!f_SearchPanel!WED1)) And ((q_FA_DOW.[Work Element
Description]) Like "*" & Forms!f_SearchPanel!WED2 & "*" Or
isnull(Forms!f_SearchPanel!WED2)) And ((q_FA_DOW.[Work Element Description])
Like "*" & Forms!f_SearchPanel!WED3 & "*" Or
isnull(Forms!f_SearchPanel!WED3)) And ((q_FA_DOW.[Work Element Description])
Like "*" & Forms!f_SearchPanel!WED4 & "*" Or
isnull(Forms!f_SearchPanel!WED4)) And ((q_FA_DOW.[Work Element Description])
Like "*" & Forms!f_SearchPanel!WED5 & "*" Or
isnull(Forms!f_SearchPanel!WED5)) And
q_FA_DOW.Active=Forms!f_SearchPanel!SearchActive)
ORDER BY q_FA_DOW.ID;
Note: everything works perfectly, exactly as I want, except for the open
recordset error.
Ideas?
Thank you.
MS Access 2003 on XP Pro
I am trying to write some error message for my user. Basically, I have a
search panel for the user to use, and if the search yields zero records,
rather than the form coming up with no results, I'd rather a mesage box pop
up and say "No Records".
So the way I thought I'd do this is if the query that feeds than form has an
empty recordset, I would pop a message box. Well, here's the code I used for
this and then here's the message. (Error Message pops on code surrounded
like <<<THIS>>>.)
Dim myDB As Database, rs As Recordset, tqn As String
Set myDB = CurrentDb
tqn = "q_search_exact"
<<<Set rs = myDB.OpenRecordset(tqn)>>>
If rs.EOF Or rs.BOF Then
DoCmd.Beep
MsgBox "Returned zero (0) results.", vbOKOnly, "Search Complete"
Else
DoCmd.OpenForm "f_search_exact", acNormal
End If
Here's the error message.
Error 3061 too few parameters. Expected 12.
The query is stored in Access. (Written in SQL but stored, so not generated
in VBA, but written as a query.) Here is the SQL for the query.
SELECT q_FA_DOW.DayOfWeek, q_FA_DOW.Fleet_Activity, q_FA_DOW.BinstoOther,
q_FA_DOW.[CCC's], q_FA_DOW.VFG, q_FA_DOW.VRT, q_FA_DOW.[GQRS CAT],
q_FA_DOW.ACTION, q_FA_DOW.[Work Element Description], q_FA_DOW.Frequency,
q_FA_DOW.[WES#], q_FA_DOW.Source, q_FA_DOW.ID, q_FA_DOW.Active
FROM q_FA_DOW
WHERE (((q_FA_DOW.Fleet_Activity)=Forms!f_SearchPanel!FASearch Or
isnull(Forms!f_SearchPanel!FASearch)) And
((q_FA_DOW.VRT)=Forms!f_SearchPanel!VRTSearch Or
isnull(Forms!f_SearchPanel!VRTSearch)) And
((q_FA_DOW.VFG)=Forms!f_SearchPanel!VFGSearch Or
isnull(Forms!f_SearchPanel!VFGSearch)) And
((q_FA_DOW.[CCC's])=Forms!f_SearchPanel!CCCSearch Or
isnull(Forms!f_SearchPanel!CCCSearch)) And
((q_FA_DOW.Action)=Forms!f_SearchPanel!ActionSearch Or
isnull(Forms!f_SearchPanel!ActionSearch)) And ((q_FA_DOW.[GQRS
CAT])=Forms!f_SearchPanel!GQRS Or isnull(Forms!f_SearchPanel!GQRS)) And
((q_FA_DOW.[Work Element Description]) Like "*" & Forms!f_SearchPanel!WED1 &
"*" Or isnull(Forms!f_SearchPanel!WED1)) And ((q_FA_DOW.[Work Element
Description]) Like "*" & Forms!f_SearchPanel!WED2 & "*" Or
isnull(Forms!f_SearchPanel!WED2)) And ((q_FA_DOW.[Work Element Description])
Like "*" & Forms!f_SearchPanel!WED3 & "*" Or
isnull(Forms!f_SearchPanel!WED3)) And ((q_FA_DOW.[Work Element Description])
Like "*" & Forms!f_SearchPanel!WED4 & "*" Or
isnull(Forms!f_SearchPanel!WED4)) And ((q_FA_DOW.[Work Element Description])
Like "*" & Forms!f_SearchPanel!WED5 & "*" Or
isnull(Forms!f_SearchPanel!WED5)) And
q_FA_DOW.Active=Forms!f_SearchPanel!SearchActive)
ORDER BY q_FA_DOW.ID;
Note: everything works perfectly, exactly as I want, except for the open
recordset error.
Ideas?
Thank you.