Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Unanswered: setting variables with a sql statment

    I am having a bit of a time trying to set a variable in vba = to a sql statment.
    this is my code:

    Dim Local_vers As String
    Dim Server_vers As String


    Server_vers = "select Version_Number from Table:_PCRKMS_User_Defaults"

    Now I tried this with out the "" because in the original form all I got back was the select statment duuuhh. When I do that I get the error need object or something like that. So does anyone have an idea about how to set a vairable with a sql statment?
    Regards
    Jim

  2. #2
    Join Date
    May 2002
    Posts
    395

    Re: setting variables with a sql statment

    Originally posted by JDionne
    I am having a bit of a time trying to set a variable in vba = to a sql statment.
    this is my code:

    Dim Local_vers As String
    Dim Server_vers As String


    Server_vers = "select Version_Number from Table:_PCRKMS_User_Defaults"

    Now I tried this with out the "" because in the original form all I got back was the select statment duuuhh. When I do that I get the error need object or something like that. So does anyone have an idea about how to set a vairable with a sql statment?
    Regards
    Jim
    Add ; at the end of your SQL statement. eg: " Select .. From tbl;"
    Hope that is it.

  3. #3
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Nope no go
    any other sugestions?
    Jim

  4. #4
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    WOOHOOOOO Screw SQL USE DLOOKUP!!!!!!!!

  5. #5
    Join Date
    May 2002
    Posts
    395

    Re: setting variables with a sql statment

    Originally posted by alicejwz
    Add ; at the end of your SQL statement. eg: " Select .. From tbl;"
    Hope that is it.
    Did you declare object variables for database and recordset?
    Dim dbs As Database
    Dim rst As Recordset
    Dim yoursqlstatement as string

    yoursqlstatement = "select ....from table:"

    Set dbs = CurrentDb()
    set rst = dbs.OpenRecordset("tablename", yoursesqlstatement"
    .
    .
    .

  6. #6
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    i actualy did try that but i got no benifit from it, maybe due to my inexperiance, but dlookup seems to be doing the trick so lets hope
    Jim

  7. #7
    Join Date
    May 2002
    Posts
    395
    Originally posted by JDionne
    i actualy did try that but i got no benifit from it, maybe due to my inexperiance, but dlookup seems to be doing the trick so lets hope
    Jim
    Good for you

Posting Permissions

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