PDA

Click to See Complete Forum and Search --> : datagrid from datacombo selection


lew
Apr 9th, 2000, 05:33 AM
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

lew
Apr 10th, 2000, 04:16 AM
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

lew
Apr 10th, 2000, 04:16 AM
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

lew
Apr 10th, 2000, 04:17 AM
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

lew
Apr 10th, 2000, 04:18 AM
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

lew
Apr 10th, 2000, 04:18 AM
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