I need to filter a form using the selection made by user from a dropdown.I have used the following code which throws an error: invalid argument - Private Sub cboLocate_AfterUpdate()
-
Dim rst As DAO.Recordset, db As Database
-
Dim strCriteria, SQL As String
-
strCriteria = "[A_LOCATION]=" & cboLocate
-
Set rst = Me.RecordsetClone
-
'rst.FindFirst (strCriteria = "[A_LOCATE]=" & cboLocate)
-
Set db = CurrentDb
-
Set rst = db.OpenRecordset("qryMIMATRIX", dbOpenDynaset, dbReadOnly, dbOptimistic)
-
If rst.NoMatch Then
-
MsgBox "No entry found"
-
Else
-
Me.FilterOn = False
-
Me.Filter = strCriteria
-
Me.FilterOn = True
-
End If
-
End Sub
The error points to the code: - Set rst = db.OpenRecordset("qryMIMATRIX", dbOpenDynaset, dbReadOnly, dbOptimistic)
-
If I simply use - Set rst = db.OpenRecordset("qryMIMATRIX")
-
I am asked to enter a parameter value.
qryMIMATRIX is a query.I also tried using -
Sql="select * from qryMIMATRIX"
-
Set rst=db.OpenRecordset(SQL)
If I do not use db.OpenRecordset() then no filtering happens.
I would like to know how I can make this work?
5 2181 NeoPa 32,557
Recognized Expert Moderator MVP
Line #8 appears perfectly correct as far as I can see. It may well be easier to use the other format to open a query (Below), but your VBA here seems fine. - Set rst = db.QueryDefs("qryMIMATRIX").OpenRecordset(Type:=, Options:=, LockEdit:=)
As your VBA seems ok, I would look at the query itself and see if that runs when opened normally.
Here's the query: - TRANSFORM First(qryMIMATRIXSELECT!A_PLANDATE) AS [FirstOfvolgende inspectie]
-
SELECT qryMIMATRIXSELECT.A_ID, qryMIMATRIXSELECT.A_PLANDATE, qryMIMATRIXSELECT.A_LOCATION, qryMIMATRIXSELECT.A_JOBNO, IIf(IsNull(qryMIMATRIXSELECT!A_PROJECTID),qryMIMATRIXSELECT!A_EQUIPDESCR,"**13M** " & qryMIMATRIXSELECT!A_EQUIPDESCR) AS exprA_EQUIPDESCR, qryMIMATRIXSELECT.A_NENGROUP, qryMIMATRIXSELECT.A_PRIORITY, qryMIMATRIXSELECT.A_MENO, qryMIMATRIXSELECT.A_DAYO
-
FROM qryMIMATRIXSELECT
-
GROUP BY qryMIMATRIXSELECT.A_ID, qryMIMATRIXSELECT.A_PLANDATE, qryMIMATRIXSELECT.A_LOCATION, qryMIMATRIXSELECT.A_JOBNO, IIf(IsNull(qryMIMATRIXSELECT!A_PROJECTID),qryMIMATRIXSELECT!A_EQUIPDESCR,"**13M** " & qryMIMATRIXSELECT!A_EQUIPDESCR), qryMIMATRIXSELECT.A_NENGROUP, qryMIMATRIXSELECT.A_PRIORITY, qryMIMATRIXSELECT.A_MENO, qryMIMATRIXSELECT.A_DAYO
-
ORDER BY qryMIMATRIXSELECT.A_PLANDATE
-
PIVOT qryMIMATRIXSELECT.periodes In ("0","2","4","6","8","10","12","14","16","18","20","22","24","26","28","30","32","34","36","38","40","42","44","46","48","50","52");
-
NeoPa 32,557
Recognized Expert Moderator MVP
I'm confused. Why would you post the SQL of the query? I can't test it for you (nor would I if I could - That's your responsibility).
I've already checked the VBA and I see nothing wrong with it. The fact that the query is a Cross-Tab is important information that would have been a good idea to include in the question, but doesn't change the understanding that the problem is with the query.
Actually, one thought occurs to me :
Although I'm pretty sure Help has nothing to say on the matter, the parameters dbReadOnly and dbOptimistic certainly make little sense together. They may be disallowed without this being documented so I would try passing parameters that make sense. Try leaving the Options parameter unset and use dbReadOnly for LockEdit instead. Also, if it's read/only, why are you using a Dynaset instead of a SnapShot?
Tried this: - Set rst = db.QueryDefs("qryMIMATRIX").OpenRecordset(dbOpenSnapshot, , dbReadOnly)
-
and - Set rst = db.OpenRecordset(SQL, dbOpenSnapshot, , dbReadOnly)
Again error 3001 saying invalid object.
NeoPa 32,557
Recognized Expert Moderator MVP NeoPa:
As your VBA seems ok, I would look at the query itself and see if that runs when opened normally.
It doesn't seem to be a VBA problem then.
What did you find when you tested the query manually as suggested in post #2?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: reneeccwest |
last post by:
Different user input boxes are automatically populated based on a
value of the dropdown box.
Can anyone help me on that?
|
by: reneeccwest |
last post by:
how can I make the value of the user input box as a desired color? (such as red)
Is it also possible to change the color in the user input box background?
RC
|
by: Ray Lavelle |
last post by:
I'm new to VB .NET. In the past when creating an application, if I
had an input form I would just call the set and get methods on the
object that mapped to my database table in order to store and...
|
by: Michael |
last post by:
Hi All,
I am working on my intranet reporting web site, by use of IIS5 + Office2000
+SQL2000.
Currently, the first step, I show user an ASP web-interface to collect user
input, keyword...
|
by: Clare |
last post by:
Hi
I have a report that is made of 4 subreports. There is no actual
information in the main report, and the record source is empty. In
the Header section of the main report, I have a text box...
| |
by: Matthew Louden |
last post by:
In ASP, if I have asppage.asp for GUI and aspprocess.asp for process
requests from database.
In asppage.asp code will be like:
<form action="aspprocess.asp" method="POST"> GUI CODE </form>
...
|
by: danielboendergaard |
last post by:
Hey
Im making a homepage in php. I use a html form to put data into mysql
and i want to make some buttons which inserts user input values into a
textarea. I have used a button like this:
<input...
|
by: joesin |
last post by:
I recently found a vulnerability on my website that allowed sql
injection. I have been trying to write some code that would clean user
data but have been running into problems. The validation still...
|
by: parshupooja |
last post by:
Hi,
I am working in Asp.Net 2.0, SQL Server, C#.
I am trying to create a User Input form which has lots of fields such as :
salutation;
Firstname:
lastname:
address:
Zip:
Phone:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |