Re: Error 91 help required

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Allen Browne (AllenBrowne_at_SeeSig.Invalid)
Date: 07/07/04


Date: Wed, 7 Jul 2004 23:06:45 +0800

This error indicates either that you have a misspelling in your query, or
else that you have a parameter that is to be supplied at runtime.

If you run the query through the interface, it can call the Expression
Service to resolve references such as:
    Forms!MyForm!MyTextBox
You cannot do that in DAO code.

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
<sandra@discussions.microsoft.com> wrote in message
news:2840b01c46431$451efb90$a401280a@phx.gbl...
> Thanks Reggie!
>
> But now I am getting 3061 error - "Too few parameters.
> Expected 2"
>
> Any ideas?
>
>
> >-----Original Message-----
> >Sanda, You need to instantiate the database object
> variable by using the set
> >statement as you did for the recordset object. I also
> changed the name of
> >your variable. Not sure if CurrentDB is a reserved word,
> but why take
> >chances!
> >
> >Dim db As DAO.Database
> >Set db = CurrentDb()
> >Set rs = db.OpenRecordset("qryFirst")
> >-- 
> >Reggie
> >
> >----------
> ><sandra@discussions.microsoft.com> wrote in message
> >news:27e1c01c46402$41fa9570$a501280a@phx.gbl...
> >> Help!
> >>
> >> I am getting an Error 91 code "Object variable or With
> >> block variable not set"
> >>
> >> I get it on
> >>   Set rs = CurrentDb.OpenRecordset("qryFirst")
> >> from the following code:
> >>
> >>   Private Sub cmdSubmit_click()
> >>
> >>   Dim rs As DAO.Recordset
> >>   Dim CurrentDb As Database
> >>
> >>   Set rs = CurrentDb.OpenRecordset("qryFirst")
> >>
> >>   rs.MoveLast    'I put this in because I've found
> >>                   sometimes it doesn't count properly
> >>                   otherwise...
> >>
> >>   If rs.RecordCount = 0 Then
> >>      MsgBox "blah"
> >>   Else
> >>      DoCmd.OpenQuery "qryFirst", acViewNormal
> >>   End If
> >>
> >>   End Sub
> >>
> >> Any ideas what's causing this error?


Relevant Pages

  • Re: access 2003
    ... Dim ctl As Control ... Dim rs As Recordset ... This sets the query definitions for choosing data to create an invoice using ... Event on combo box: Private Sub ChooseCust_AfterUpdate ...
    (microsoft.public.access.conversion)
  • Re: Listbox filtering on a form
    ... you can select from a query instead of a table. ... Dim varItem As Variant ... Private Sub List200_AfterUpdate ... Dim cnt, i As Integer ...
    (microsoft.public.access.formscoding)
  • Re: Multiple table in dataset query
    ... If a row is marked as Modified, it will run your query defined in the ... Update Command object. ... Dim UpdateStaffCmd As New OleDb.OleDbCommand ... Private Sub frmStaff_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: access 2003
    ... I've noticed is that it seems you should be using a parameter query to ... Dim db As DAO.Database ... then the recordset contains no records: ... Private Sub ChooseCust_AfterUpdate ...
    (microsoft.public.access.conversion)
  • Re: Updated query via VBA
    ... >The SQL of the update query is ... >Private Sub Update_Click ... > Dim qdf As DAO.QueryDef ... > Dim strOffice As String ...
    (microsoft.public.access.modulesdaovba)