"Data type mismatch in criteria expression."

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Private Sub Combo24_AfterUpdate()

Dim strSQL As String
strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = "
strSQL = strSQL & Me!Combo24
Me!Combo36.RowSourceType = "Table/Query"
Me!Combo36.RowSource = strSQL

End Sub
 
If the "Type" field type is text, then try this, adding a single quote before
and after

strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = '"
strSQL = strSQL & Me!Combo24 & "'"
 
Thanks Ofer, that eliminated the error.

But now I'm back to my original problem: the second combo box is not
populated with anything after I select a value in the first combo. I've
written the sql with a single criteria in quotes, to see if I could force
some data to return to the second combo, and that did work. But trying to
use the value selected in the first combo has not worked once for me, and
I've been through Dev Ashish's site, and searches here, and gotten replies
too, all without success. I'm dead in the water atm.


Ofer said:
If the "Type" field type is text, then try this, adding a single quote before
and after

strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = '"
strSQL = strSQL & Me!Combo24 & "'"

--
\\// Live Long and Prosper \\//
BS"D


Ricter said:
Private Sub Combo24_AfterUpdate()

Dim strSQL As String
strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = "
strSQL = strSQL & Me!Combo24
Me!Combo36.RowSourceType = "Table/Query"
Me!Combo36.RowSource = strSQL

End Sub
 
Try to add in the end of the code

Me!Combo36.Requery

--
\\// Live Long and Prosper \\//
BS"D


Ricter said:
Thanks Ofer, that eliminated the error.

But now I'm back to my original problem: the second combo box is not
populated with anything after I select a value in the first combo. I've
written the sql with a single criteria in quotes, to see if I could force
some data to return to the second combo, and that did work. But trying to
use the value selected in the first combo has not worked once for me, and
I've been through Dev Ashish's site, and searches here, and gotten replies
too, all without success. I'm dead in the water atm.


Ofer said:
If the "Type" field type is text, then try this, adding a single quote before
and after

strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = '"
strSQL = strSQL & Me!Combo24 & "'"

--
\\// Live Long and Prosper \\//
BS"D


Ricter said:
Private Sub Combo24_AfterUpdate()

Dim strSQL As String
strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = "
strSQL = strSQL & Me!Combo24
Me!Combo36.RowSourceType = "Table/Query"
Me!Combo36.RowSource = strSQL

End Sub
 
Done, again actually. Had that in before.

My code now:

Private Sub Combo24_AfterUpdate()

Dim strSQL As String
strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = '"
strSQL = strSQL & Me!Combo24 & "'"
Me!Combo36.RowSourceType = "Table/Query"
Me!Combo36.RowSource = strSQL

Me!Combo36.Requery

End Sub

Sadly, I'm still getting a blank row when I click the second combo...

Ofer said:
Try to add in the end of the code

Me!Combo36.Requery

--
\\// Live Long and Prosper \\//
BS"D


Ricter said:
Thanks Ofer, that eliminated the error.

But now I'm back to my original problem: the second combo box is not
populated with anything after I select a value in the first combo. I've
written the sql with a single criteria in quotes, to see if I could force
some data to return to the second combo, and that did work. But trying to
use the value selected in the first combo has not worked once for me, and
I've been through Dev Ashish's site, and searches here, and gotten replies
too, all without success. I'm dead in the water atm.


Ofer said:
If the "Type" field type is text, then try this, adding a single quote before
and after

strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = '"
strSQL = strSQL & Me!Combo24 & "'"

--
\\// Live Long and Prosper \\//
BS"D


:

Private Sub Combo24_AfterUpdate()

Dim strSQL As String
strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = "
strSQL = strSQL & Me!Combo24
Me!Combo36.RowSourceType = "Table/Query"
Me!Combo36.RowSource = strSQL

End Sub
 
"bump" (test)

Ofer said:
Try to add in the end of the code

Me!Combo36.Requery

--
\\// Live Long and Prosper \\//
BS"D


Ricter said:
Thanks Ofer, that eliminated the error.

But now I'm back to my original problem: the second combo box is not
populated with anything after I select a value in the first combo. I've
written the sql with a single criteria in quotes, to see if I could force
some data to return to the second combo, and that did work. But trying to
use the value selected in the first combo has not worked once for me, and
I've been through Dev Ashish's site, and searches here, and gotten replies
too, all without success. I'm dead in the water atm.


Ofer said:
If the "Type" field type is text, then try this, adding a single quote before
and after

strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = '"
strSQL = strSQL & Me!Combo24 & "'"

--
\\// Live Long and Prosper \\//
BS"D


:

Private Sub Combo24_AfterUpdate()

Dim strSQL As String
strSQL = "Select [ID],[Material] "
strSQL = strSQL & "from tblItemMats "
strSQL = strSQL & "where [Type] = "
strSQL = strSQL & Me!Combo24
Me!Combo36.RowSourceType = "Table/Query"
Me!Combo36.RowSource = strSQL

End Sub
 
Back
Top