Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Toasty is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    The Netherlands
    Posts
    18
    I allready tried the other dbOpen options. No results and the same error.



    As you can see in the TestFile that I have sent, the form is based on the same query as the recordset. Could it have anything to do with that?

  2. #17
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    No, if you want your recordset to reflect what is in the form's recordset, use RecordsetClone.

    I would be explicit and make my declarations DAO.
    Dim db As DAO. Database
    Dim rstOpenPurchaseOrders As DAO.Recordset

  3. #18
    Toasty is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    The Netherlands
    Posts
    18
    Wow, okay thanks! That worked concerning the Too few parameters error. But now I only want the records that are displayed in my subform. Where should I edit my code to get the recordset that I need? And not everything that is in the query?

  4. #19
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You can make a copy of your Recordset using
    Set rstOpenPurchaseOrders = Me.recordsetclone

    Note that your db object is not used. So no need to declare it or initialize it.

  5. #20
    Toasty is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    The Netherlands
    Posts
    18
    I already tried that but it keeps on telling me that there is an Invalid use of "Me" keyword. Could you explain how my code would look like? Would be perfect!

  6. #21
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Sure...

    Code:
    Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone

    I retrieved that example from this working code
    Code:
    Dim rs As DAO.Recordset
    If Not IsNull(Me.ComboboxName) Then
        If Me.Dirty Then
            Me.Dirty = False
        End If
        Set rs = Me.RecordsetClone
        rs.FindFirst "[EquipNum] = '" & Me.ComboboxName.Column(1) & "'"
        If rs.NoMatch Then
            MsgBox ("Not found")
        Else
              If rs.Bookmarkable = False Then
              MsgBox "Can't bookmark this record"
              Else
              Me.Bookmark = rs.Bookmark
              End If
        End If
        Set rs = Nothing
    End If

    If you are unable to get intellisence when typing Me and then dot within your subprocedure, you have an issue with misplaced code/text within your form's module.

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Looking at the original query and code in the posted db:

    The 'too few parameters' error is caused by the IIf() expression in the query. Don't use the query. Change the code to:

    strSQL = "SELECT * FROM Partnrs WHERE po_partnr = '" & Me.partnrFilter & "';"

    However, recommend a combobox instead of textbox to enter/select partner then filter on the ID field.

    Then the entire procedure needs to be behind the form, not in a general module, if you want to use Me qualifier.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #23
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Thanks June, wasn't looking at that.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 17
    Last Post: 07-15-2014, 06:17 AM
  2. E-Mail code adding #mailto:
    By SMcGrath in forum Programming
    Replies: 2
    Last Post: 12-23-2013, 11:47 AM
  3. Replies: 5
    Last Post: 10-29-2012, 05:53 AM
  4. Replies: 1
    Last Post: 09-14-2012, 10:27 AM
  5. Replies: 1
    Last Post: 05-18-2011, 09:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums