Results 1 to 6 of 6

Thread: datagrid from datacombo selection

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    8
    I would like to populate a datagrid using the selection from a datacombo. I have created a query "advQuery" and append the datacombo text as "WHERE = " criteria. When I run this, I get a 'data type mismatch'. Can anyone help? My code is below.
    Thank you in advance.
    lew

    Private Sub dbcboOrderNo_Click(Area As Integer)
    Dim advQuery As String
    advQuery = _
    "SELECT " & _
    "Advertisement.Adver_Spot_ID, " & _
    "Advertisement.Adver_Frequency, " & _
    "Advertisement.Adver_Start_Date, " & _
    "Advertisement.Adver_End_Date " & _
    "FROM [Order] INNER JOIN Advertisement " & _
    "ON Order.Order_No = Advertisement.Order_No " & _
    "WHERE Advertisement.Order_No = "
    If Area = dbcAreaList Then
    On Error Resume Next
    ' Create a new query for datOrderAdv record source
    ' which uses the results of the datacombo selection.
    ' The original record source for datOrderAdv
    ' was: SELECT * FROM Advertisement
    datOrderAdv.RecordSource = advQuery & _
    "'" & dbcboOrderNo.Text & "'"
    datOrderAdv.Refresh

    'Populate text boxes associated with the selected order
    datOrder.Recordset.Bookmark = dbcboOrderNo.SelectedItem
    txtOrderDate = datOrder.Recordset("Order_Date")
    txtPONo = datOrder.Recordset("Order_Purchase_Order_Num")
    datClientOrder.Recordset.Bookmark = dbcboOrderNo.SelectedItem
    txtCoName = datClientOrder.Recordset("Client_Name")
    datOrderAdv.Recordset.Bookmark = dbcboOrderNo.SelectedItem

    End If
    End Sub

  2. #2

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    8
    I found a solution, in case anyone else runs into the same problem. The statement to append the datacombo value to the SQL statement didn't require the surrounding "'". 'Also preceded it with Val statement.

    Was:
    datOrderAdv.RecordSource = advQuery & _
    "'" & dbcboOrderNo.Text & "'"

    Corrected version:
    datOrderAdv.RecordSource = advQuery & _
    & Val(dbcboOrderNo.Text)

    What I would like to understand is when to use the single quotes. The field populating the datacombo is a number. Are the single quotes only required for strings?
    Thanks,
    lew

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    8
    I found a solution, in case anyone else runs into the same problem. The statement to append the datacombo value to the SQL statement didn't require the surrounding "'". 'Also preceded it with Val statement.

    Was:
    datOrderAdv.RecordSource = advQuery & _
    "'" & dbcboOrderNo.Text & "'"

    Corrected version:
    datOrderAdv.RecordSource = advQuery & _
    & Val(dbcboOrderNo.Text)

    What I would like to understand is when to use the single quotes. The field populating the datacombo is a number. Are the single quotes only required for strings?
    Thanks,
    lew

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    8
    I found a solution, in case anyone else runs into the same problem. The statement to append the datacombo value to the SQL statement didn't require the surrounding "'". 'Also preceded it with Val statement.

    Was:
    datOrderAdv.RecordSource = advQuery & _
    "'" & dbcboOrderNo.Text & "'"

    Corrected version:
    datOrderAdv.RecordSource = advQuery & _
    & Val(dbcboOrderNo.Text)

    What I would like to understand is when to use the single quotes. The field populating the datacombo is a number. Are the single quotes only required for strings?
    Thanks,
    lew

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    8
    I found a solution, in case anyone else runs into the same problem. The statement to append the datacombo value to the SQL statement didn't require the surrounding "'". 'Also preceded it with Val statement.

    Was:
    datOrderAdv.RecordSource = advQuery & _
    "'" & dbcboOrderNo.Text & "'"

    Corrected version:
    datOrderAdv.RecordSource = advQuery & _
    & Val(dbcboOrderNo.Text)

    What I would like to understand is when to use the single quotes. The field populating the datacombo is a number. Are the single quotes only required for strings?
    Thanks,
    lew

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    8

    solution found

    I found a solution, in case anyone else runs into the same problem. The statement to append the datacombo value to the SQL statement didn't require the surrounding "'". 'Also preceded it with Val statement.

    Was:
    datOrderAdv.RecordSource = advQuery & _
    "'" & dbcboOrderNo.Text & "'"

    Corrected working version:
    datOrderAdv.RecordSource = advQuery & _
    & Val(dbcboOrderNo.Text)

    What I would like to understand is when to use the single quotes. The field populating the datacombo is a number. Are the single quotes only required for strings?
    Thanks,
    lew

Posting Permissions

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



Click Here to Expand Forum to Full Width