"Data type mismatch in criteria expression."

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
 
G

Guest

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 & "'"
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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
 
G

Guest

"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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top