Re: Translation of SQL for VBA



What are you doing with the SQL string when it's built? That can affect how
you would handle this.

In general, you would concatenate the actual value from the parameter into
the string:

MyString = "WHERE VcValue.Site=" & [forms]![VcValueSubform]![site] & _
" AND VcValue.Year=" & [forms]![VcValueSubform]![txtSubyear]

(above assumes that both fields are numeric).

--

Ken Snell
<MS ACCESS MVP>

"Kou Vang" <KouVang@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AAA8A202-0E7F-4CE1-864D-ACFAB3317B8F@xxxxxxxxxxxxxxxx
>I have not been able to find a translation of 2 conditions of a query to be
> properly coded in VBA. I know this is pretty basic, but I'm struggling.
> How
> do I say this in my strSQL string in VBA? Thanks.
>
> WHERE (((VcValue.Site)=[forms]![VcValueSubform]![site]) AND
> ((VcValue.Year)=[forms]![VcValueSubform]![txtSubyear]));
>


.



Relevant Pages

  • Re: Update existing values incrementally w/UPDATE SQL
    ... and in the book; Access 2007 VBA Programmer's Reference. ... As far as quotes go, this was one of the trickiest ... Consider vba's interpretation of a string: ... when an SQL is processed (I use an SQL example because it is the most ...
    (microsoft.public.access.modulesdaovba)
  • Re: Update existing values incrementally w/UPDATE SQL
    ... pretend that Me.txtString is a control on your form, ... You cant put Me.txtString inside the double quotes, or VBA just reads it as a ... and in the book; Access 2007 VBA Programmer's Reference. ... when an SQL is processed (I use an SQL example because it is the most ...
    (microsoft.public.access.modulesdaovba)
  • Re: Please help:need to read XML, edit, and write back to XML file
    ... I copied Astrid's code into a VBA module and ran it, ... give me any of the tags. ... string, as the scripting code gave me. ... reading, writing or appending. ...
    (microsoft.public.word.vba.general)
  • Re: My Selected print in the list box does not work
    ... Public Function BuildWhereCondition(strControl As String) As String ... Dim strWhereLst As String ... HERE IS THE VBA OF A COMMAND: ...
    (microsoft.public.access.formscoding)
  • Re: Trying to create dynamic VBA code (or wasting my time?)
    ... VBA isn't designed to handle self-modifying code. ... Operator As String) As Variant ... how to manipulate recordsets, having done so before. ... Dim stringBuff As String ...
    (microsoft.public.access.modulesdaovba)