I need help creating a search form. I have no knowledge of SQL and I've looked at many examples and can't seem to figure this out. I've attached the database and hopefully someone can give me some help with the SQL code to create this search form. I created the layout of how I want to the search form to look like and it is saved as "ReadingSearchForm". It has 5 multi-select list boxes and 4 combo boxes. I want the user to select the criteria from the list boxes and combo boxes and the information will appear in a subform.
Answered on the other board. On search button click: use vb code to determine what user selected.
Then put the sql into the form to view the results.
dim sSql as string, sWhere as string
if not isnull(cboState) then sWhere = sWhere & " and [state]='" & cboState & "'"
if not IsNull(txtName) then sWhere = sWhere & " and [Name]='" & txtName & "'"
if not IsNull(chkContact) then sWhere = sWhere & " and [Contact]=" & chkContact.value
'remove 1st And
sSql = "SELECT * FROM tblCompany WHERE "
sSql = sSql & sWhere
frmResults.Recordsource = sSql