Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    83

    Unanswered: help needed with sql

    Good morning,

    I need a help in writing the following SQL in VBA,
    The SQL expression is:
    "Select distinct ClinicName from tblClinic Where Location = 'Lakewood'
    order by Clinicname"

    in VBA, I am writing as:
    strSQL = "SELECT Distinct ClinicName FROM tblClinic " _
    & " WHERE Location = '" & lakewood & "'" & "" _
    & " Order By ClinicName"

    while executing it is as follows,
    Select distinct ClinicName from tblClinic Where Location = " Order by ClinicName

    Your help is greatly appreciated,
    Thanks in advance

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: help needed with sql

    Originally posted by skodidhi
    Good morning,

    I need a help in writing the following SQL in VBA,
    The SQL expression is:
    "Select distinct ClinicName from tblClinic Where Location = 'Lakewood'
    order by Clinicname"

    in VBA, I am writing as:
    strSQL = "SELECT Distinct ClinicName FROM tblClinic " _
    & " WHERE Location = '" & lakewood & "'" & "" _
    & " Order By ClinicName"

    while executing it is as follows,
    Select distinct ClinicName from tblClinic Where Location = " Order by ClinicName

    Your help is greatly appreciated,
    Thanks in advance
    Do you get your data form a Form ? Imean that varialble lakewood

    If yes then use

    strSQL = "SELECT Distinct ClinicName FROM tblClinic " _
    & " WHERE Location = '" & forms!yourFormName.lakewood & "'" & "" _
    & " Order By ClinicName"

  3. #3
    Join Date
    Feb 2004
    Location
    Houston, Texas
    Posts
    45
    This is how I would write it:
    (I'm assumming that lakewood is a string variable)

    strSQL = "SELECT Distinct ClinicName FROM tblClinic "
    strSQL = strSQL & "WHERE Location = '" & lakewood & "' "
    strSQL = strSQL & "Order By ClinicName"
    ..rtk

  4. #4
    Join Date
    Sep 2003
    Posts
    83

    help needed with SQL

    Originally posted by rtkracht
    This is how I would write it:
    (I'm assumming that lakewood is a string variable)

    strSQL = "SELECT Distinct ClinicName FROM tblClinic "
    strSQL = strSQL & "WHERE Location = '" & lakewood & "' "
    strSQL = strSQL & "Order By ClinicName"
    ..rtk
    Thanks everyone. I got it working with the following code, (Lakewood) is the value.
    strSQL = "SELECT Distinct ClinicName FROM tblClinic " _
    & " WHERE Location = 'Lakewood ' " _
    & " Order By ClinicName"

    thanks for the quick response.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •