Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2012
    Posts
    31

    Unanswered: Problem in my query

    I have a problem with my query..
    This is my orinal code:

    Private Sub Form_Load()
    Dim SiteCodeName, SiteLocationName

    AccntType = DLookup("Usertype", "User", "UserName= [Forms]![LogIn]![txtUserName]")
    SiteCodeName = DLookup("SiteCode", "User", "UserName= [Forms]![LogIn]![txtUserName]")
    SiteLocationName = DLookup("SiteLocation", "SiteCode", "SiteCode='" & SiteCodeName & "'")
    dfsds = MsgBox(SiteLocationName)

    Dim SQLSitecode
    Dim extSitecode As String
    extSitecode = ""

    SQLSitecode = "QEmployeeList"
    If SiteLocationName Like "Bacolod" & "*" Then
    extSitecode = " WHERE SiteCode='" & 292 & "' And Employee.SiteCode= '" & 353 & "'"
    Else
    extSitecode = " WHERE SiteCode='" & SiteCodeName & "'"
    End If
    SQLSitecode = SQLSitecode + extSitecode + ";"
    Me.RecordSource = SQLSitecode

    End Sub


    But i got this kind of error.Please see attach file.
    Anyone can help me..Thanx in advance..
    Attached Thumbnails Attached Thumbnails problem.JPG  

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Try:
    Code:
    SQLSitecode = "SELECT * FROM QEmployeeList"
    Or copy the SQL expression of the query QEmployeeList and assign it to SQLSitecode:
    Code:
    SQLSitecode = "--> The SQL expression of QEmployeeList goes here <--"
    Have a nice day!

  3. #3
    Join Date
    Dec 2012
    Posts
    31
    Tnx a lot that works fine....

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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