Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    Unanswered: can anyone verify my sql behind a form

    Ok, I am using following version. I don't want to put all the fields in sql (table.field1, table.field2). Instead, I want to feed two field (txtYear and cboAdmin) from the form to the query (qryindividual1 for txtyear and qryindividual2 for cboadmin) and let the query run.

    I am using following query but this time i get a error. "The select statement includes a reserve word or an argument name that is mispelled or missing, or the punctuation is incorrect."

    Please let me know where is the problem.
    Thanks / Dianna


    =============================================
    Function Query4Data()

    Dim strSQL As String
    Dim qdfApp As QueryDef

    DoCmd.SetWarnings False

    Set qdapp = currentdb.QueryDefs("qryIndividual2")

    strSQL$ = "Select " & _
    "FROM qryindividual2 " & _
    "where(qryindividual2.Year = # " & Me!txtYear & " # ) And (qryindividual2.Primary_Administrator = Me!cboAdmin);"
    qdapp.SQL = strSQL
    DoCmd.OpenQuery "qryindividual2"

    MyRS.close
    qdfApp.close
    DoCmd.SetWarnings True

    End Function
    ==============================================
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    strSQL$ = "Select * " & _
    "FROM qryindividual2 " & _
    "where(qryindividual2.Year = # " & Me!txtYear & " # ) And (qryindividual2.Primary_Administrator = Me!cboAdmin);"

  3. #3
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    "Object Required" Error

    Hi CyberLynx,

    I am getting "Object Required" error. Also, it's not keeping my qryindividual2 in orignal shape. It's deleting everying from that query. Your help will be very much appreciated. I have been struggling for days.

    Thanks for helping me.

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    To get this going, I placed this SQL statement into the RowSource property of your cboAdmin combobox located in the dashboard:

    Code:
    SELECT tbl_admin.Contact FROM tbl_admin ORDER BY tbl_admin.Contact;
    I then modified the SQL statement located in the Query4Data() function, also located in the dashboard form module:

    Code:
    strSQL$ = "SELECT * FROM qryIndividual2 WHERE (([Year] = '" &  _
    Me.txtYear & "') And ([Primary_Administrator] = '" & Me.cboAdmin & "'));"
    I have added this to the txtYear field (in dashboard) MouseUp event. You may find it handy.

    Code:
    Private Sub txtYear_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If IsNull(Me.txtYear) Then SendKeys "{Home}"
    End Sub
    I did receive a "Circular Reference" error but you will need to sort that out by modifying the way you are going about getting the required data.

    Hope this helps in some way...

  5. #5
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    "Object Required"

    any idea why I am receiving object required error.

  6. #6
    Join Date
    Nov 2003
    Posts
    1,487
    Something must be either missing or misspelled within a SQL statement.
    Make sure the table(s) and field name(s) are corrently spelled, etc.

Posting Permissions

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