Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Location
    SLC, UT
    Posts
    11

    Unanswered: Problems with my SQL statement

    I have the following code:

    Code:
    Dim Item As String, Qty As Double
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim Time As Double
    Me.Refresh
    Item = Forms![Ins - Daily Log]![Ins - Daily Log Items]![Item]
    Qty = Forms![Ins - Daily Log]![Ins - Daily Log Items]![Qty]
    Debug.Print Item & " " & Qty
    SQL = "SELECT * " & _
            "FROM [Installation Items] " & _
            "WHERE [Installation Items]![Installation Item]= '" & [Item] & "'"
    
    Debug.Print SQL
    Set db = CurrentDb
    Set rs = db.OpenRecordset(SQL)
    
    Debug.Print rs![Installation Item] & " " & rs!Time & "min."
    Forms![Ins - Daily Log]![Ins - Daily Log Items]![unitTime] = Time
    Debug.Print rs![Time]
    Forms![Ins - Daily Log]![Ins - Daily Log Items]![ExtTime] = Time * Qty
    Debug.Print rs![Time] * Qty
    The results are correct as long as my input (or my [Item]) is a single word. When I have a multiple word value, I get an error #3021 "No current Record". What am I doing wrong that would cause a problem with my SQL statement when I have more than one word?

    Please help
    Thanks,
    Scott

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Try this:

    Item = Forms("Ins - Daily Log")("Ins - Daily Log Items").Form.Item
    Qty = Forms("Ins - Daily Log")("Ins - Daily Log Items").Form.Qty

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


Posting Permissions

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