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?
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?
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
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?
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.
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!
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.
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.
Thanks June, wasn't looking at that.