Hi All,
I have the following code I am wanting to add a WHERE clause and I have tried adding it almost everywhere, but it does not work. I don't get an error, but don't get what I want.
Private Sub cmdViewSources_Click()
wherestring = vbNullString
If IsNull(txtSourceKeyword) Then
FormIndex.RowSource = "SELECT tbl_material_description.[HOMOG_MATERIAL_ID], tbl_material_description.[BUILDING_ID] FROM tbl_material_description ORDER BY tbl_material_description.[HOMOG_MATERIAL_ID];"
Else
strWildcard = txtSourceKeyword
wherestring = "WHERE(((tbl_material_description.[HOMOG_MATERIAL_ID]) like ""*" & strWildcard & "*""))"
FormIndex.RowSource = "SELECT tbl_material_description.[HOMOG_MATERIAL_ID], tbl_material_description.[BUILDING_ID] FROM tbl_material_description " & wherestring & " ORDER BY tbl_material_description.[HOMOG_MATERIAL_ID];"
End If
End Sub
I have a list box and it gives me the results I want. Basically, the materials per building. Now when I do a search on the list box with or without wildcards I want it to also give me the materials for just one building. Right now when I click on the cmd button (code above). I get all the materials for all the buildings.
The record source for the list box is the following and again it gives me what I want; SELECT tbl_material_description.HOMOG_MATERIAL_ID, tbl_material_description.BUILDING_ID FROM tbl_material_description WHERE tbl_material_description.BUILDING_ID=forms!frm_main_data_entry.building_id ORDER BY tbl_material_description.HOMOG_MATERIAL_ID;
So, I want to add the WHERE above to the cmd button code so it too gives me the materials for the particular building I am on.
Hope it makes sense.
thanks a BUNCH!
I have the following code I am wanting to add a WHERE clause and I have tried adding it almost everywhere, but it does not work. I don't get an error, but don't get what I want.
Private Sub cmdViewSources_Click()
wherestring = vbNullString
If IsNull(txtSourceKeyword) Then
FormIndex.RowSource = "SELECT tbl_material_description.[HOMOG_MATERIAL_ID], tbl_material_description.[BUILDING_ID] FROM tbl_material_description ORDER BY tbl_material_description.[HOMOG_MATERIAL_ID];"
Else
strWildcard = txtSourceKeyword
wherestring = "WHERE(((tbl_material_description.[HOMOG_MATERIAL_ID]) like ""*" & strWildcard & "*""))"
FormIndex.RowSource = "SELECT tbl_material_description.[HOMOG_MATERIAL_ID], tbl_material_description.[BUILDING_ID] FROM tbl_material_description " & wherestring & " ORDER BY tbl_material_description.[HOMOG_MATERIAL_ID];"
End If
End Sub
I have a list box and it gives me the results I want. Basically, the materials per building. Now when I do a search on the list box with or without wildcards I want it to also give me the materials for just one building. Right now when I click on the cmd button (code above). I get all the materials for all the buildings.
The record source for the list box is the following and again it gives me what I want; SELECT tbl_material_description.HOMOG_MATERIAL_ID, tbl_material_description.BUILDING_ID FROM tbl_material_description WHERE tbl_material_description.BUILDING_ID=forms!frm_main_data_entry.building_id ORDER BY tbl_material_description.HOMOG_MATERIAL_ID;
So, I want to add the WHERE above to the cmd button code so it too gives me the materials for the particular building I am on.
Hope it makes sense.
thanks a BUNCH!