Re: Dynamic WHERE statement or criteria



When you have a parameter in a query, SET the .PARAMETER object variable before opening the RecordSet.

David wrote:
This is SO frustrating, as I did this ages ago, but have since lost the code and I've been trawling the internet all day.

All I want to do is pass an argument to a select query. The field name is 'Authority Type', in table 'Authority'. I'm positive there was a docmd function or something similar. I tried using .parameter(), but don't quite get how that works. I stuck some dummy criteria in the query, but the parameter.count value never showed more than 0. Is a parameter something else entirely? RETARDED.

Is there not something like qdf.execute(Where options) or something???? I just need to pass the field name and lookup value!!!

Dim stDocName As String
Dim db As Database
Dim rs As DAO.Recordset
Dim qdf As QueryDef


Set db = CurrentDb
Set qdf = db.QueryDefs("Authorities") 'Authorities is a basic two-field query
Set rs = qdf.OpenRecordset
Do While rs.EOF = False
thisAuthority = rs(1).Value
MsgBox thisAuthority
rs.MoveNext
Loop
.



Relevant Pages

  • RE: Breaking down imported information
    ... Single-record append query: ... ' Check if at EOF of Recordset (rsDataViaCode) ... ' if at EOF Exit Do. ... Dim rsDataViaCode As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: LDAP query information
    ... Copyright 1985-2001 Microsoft Corp. ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: LDAP query information
    ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ... Yes, the script uses ADO to query AD directly, which is very efficient - no ...
    (microsoft.public.windows.server.scripting)
  • Re: Need WMI script
    ... I also assume that strGroupName is ... If instead strDomainName is the NetBIOS name of a domain, ... Dim adoCommand, adoConnection, strBase, strFilter, strAttributes, xmlDoc, ... ' Construct the LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: Need WMI script
    ... I also assume that strGroupName is ... Dim adoCommand, adoConnection, strBase, strFilter, strAttributes, xmlDoc, ... ' Construct the LDAP syntax query. ... However, if you use the cscript host, ...
    (microsoft.public.windows.server.scripting)