Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

vb code to Test results of a query is missing something

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jonefer - 03 Mar 2005 21:09 GMT
I have some simple code that tests the result of a query before opening a
form with those results...

This has previously worked with no problems... however, what I'm doing
differently in this instance is that the query I'm testing is getting its
parameter from a combo box on a form (cmbGrpSearch).  Is this why I'm getting
the following error:

"Run time Error 3061 Too Few Parameters.  Expected 1"

when I run the following code:

'==============================================
Dim db As DAO.Database
   Dim rsChk As DAO.Recordset
   
   Set db = CurrentDb
   
   Set rsChk = db.OpenRecordset("qryGroupSearchResults", dbOpenForwardOnly)
   
   With rsChk
       If Not .EOF And Not .BOF Then
           DoCmd.OpenForm "frmGrpSearchResults"
       Else
           MsgBox "There are no subscribers currently using group #: " &
Me.cmbGrpSearch, vbInformation, "No Data Found!"
       End If
   End With

Set rsChk = Nothing

'=================================================

What should I do to fix it?
Ken Snell [MVP] - 03 Mar 2005 21:24 GMT
You would need to provide the value of the parameter to the query before you
open the recordset. This is commonly done in code.

However, for your situation, I would not open a recordset. Instead, I would
use the DCount function to test the query. Much simpler code.

       If DCount("*", "qryGroupSearchResults") > 0 Then
           DoCmd.OpenForm "frmGrpSearchResults"
       Else
           MsgBox "There are no subscribers currently using group #: " &
Me.cmbGrpSearch, vbInformation, "No Data Found!"
       End If

Signature

       Ken Snell
<MS ACCESS MVP>

>I have some simple code that tests the result of a query before opening a
> form with those results...
[quoted text clipped - 32 lines]
>
> What should I do to fix it?
jonefer - 03 Mar 2005 23:55 GMT
That was a much simpler option to the other one.
Thank you.

> You would need to provide the value of the parameter to the query before you
> open the recordset. This is commonly done in code.
[quoted text clipped - 45 lines]
> >
> > What should I do to fix it?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.