|
-
Apr 9th, 2000, 05:33 AM
#1
Thread Starter
New Member
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
-
Apr 10th, 2000, 04:16 AM
#2
Thread Starter
New Member
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
-
Apr 10th, 2000, 04:16 AM
#3
Thread Starter
New Member
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
-
Apr 10th, 2000, 04:17 AM
#4
Thread Starter
New Member
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
-
Apr 10th, 2000, 04:18 AM
#5
Thread Starter
New Member
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
-
Apr 10th, 2000, 04:18 AM
#6
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|