S
S Jackson
I have the following expression in my Query:
Like Eval("InputBox$(""Enter first part of case name, e.g. New
Hope"",""Search Cases"")") & "*"
However, I am trying to design a database for multiple users and although
the above expression works great, but if the user does not make an entry
into the InputBox or enters information that does not match a record, the
form opens up blank. I am afraid this will confuse some users and would
like to have a message box come up instead advising the user that there are
not matching entries. I don't think I can do this with a query, can I?
So the alternative was to create a dialog form with VB code, but the SQL is
so long and complicated - ugh!
I started by creating a dialog form and inserting a text box called
"txtSearch."
I want the user to enter part of the text he is searching for in txtSearch
and then click OK. Under the onclick event for the OK button I tried
beginning with the following (Note I have not built the If -no records found
statement yet). I cut and pasted my SQL from my original parameter query and
modified the WHERE clause (I haven't added the & "*" because I am not sure
of the proper syntax). Anway, I thought I would start here and try to get
this working first, but I am getting a syntax error. I am pretty sure it is
in the WHERE statement, but I can't figure it out. Any ideas anyone?
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCaselkp"
stLinkCriteria = "SELECT tblCaseInfo.CaseName, tblStatus.ClosedDate,
tblCaseInfo.DHSNo, " _
& " tlbCaseInfo.SOAHNo, tblCaseInfo.Region, tblCaseInfo.NoticeDate,
tblCaseInfo.Fieldofc, " _
& " tblCaseInfo.AppealDate, tblCaseInfo.AssignDate,
tblCaseInfo.DHSAttny, tblCaseInfo.Asstnt, " _
& " tblCaseInfo.Vendor, tblCaseInfo.Facility,
tblCaseInfo.Facility-PetAddy, tblCaseInfo.Facility-PetCity, " _
& " tblCaseInfo.Facility-PetState, tblCaseInfo.Facility-PetZip,
tblCaseInfo.Facility-PetPh, " _
& " tblCaseInfo.Facility-PetFax, tblCaseInfwner, tblCaseInfo.RepID,
tblCaseInfo.Program, " _
& " tblCaseInfo.Action, tblCaseInfo.Amt, tblCaseInfo.Rate1,
tblCaseInfo.Start1, tblCaseInfo.End1, " _
& " tblCaseInfo.Rate2, tblCaseInfo.Start2, tblCaseInfo.End2,
tblCaseInfo.Sanction, " _
& " tblCaseInfo.Surveys, tblCaseInfo.IDR, tblCaseInfo.TAC,
tblCaseInfo.ViolationDescrip, " _
& " tblCaseInfo.Comment, tblRepresentatives, tblStatus.StatusRptNotes,
tblStatus.BankruptyEntity, " _
& " tblStatus.BankruptDate, tblStatus.Bankruptcy, tblStatus.Disposition,
" _
& " tblStatus.CSAAmt, tblStatus.BoxNo, tblRegion.SUBOFC, tblRegion.PM, "
_
& " tblRegion.PMPH, tblRegion.Ext, tblRegion.Region, " _
& " FROM ((tblRepresentatives RIGHT JOIN tblCaseInfo ON
tblRepresentatives.ID = tblCaseInfo.RepID), " _
& " LEFT JOIN tblRegion ON tblCaseInfo.FieldOfc = tblRegion.ID) LEFT
JOIN tblStatus ON tblCaseInfo.DHSNo = tblStatus.DHSNo, " _
& " WHERE tblCaseInfo.CaseName LIKE " & Me.txtSearch & "" _
& " AND tblStatus.ClosedDate Is Null, " _
& " ORDER BY tblCaseInfo.CaseName; "
DoCmd.OpenForm stDocName, , , stLinkCriteria
Like Eval("InputBox$(""Enter first part of case name, e.g. New
Hope"",""Search Cases"")") & "*"
However, I am trying to design a database for multiple users and although
the above expression works great, but if the user does not make an entry
into the InputBox or enters information that does not match a record, the
form opens up blank. I am afraid this will confuse some users and would
like to have a message box come up instead advising the user that there are
not matching entries. I don't think I can do this with a query, can I?
So the alternative was to create a dialog form with VB code, but the SQL is
so long and complicated - ugh!
I started by creating a dialog form and inserting a text box called
"txtSearch."
I want the user to enter part of the text he is searching for in txtSearch
and then click OK. Under the onclick event for the OK button I tried
beginning with the following (Note I have not built the If -no records found
statement yet). I cut and pasted my SQL from my original parameter query and
modified the WHERE clause (I haven't added the & "*" because I am not sure
of the proper syntax). Anway, I thought I would start here and try to get
this working first, but I am getting a syntax error. I am pretty sure it is
in the WHERE statement, but I can't figure it out. Any ideas anyone?
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCaselkp"
stLinkCriteria = "SELECT tblCaseInfo.CaseName, tblStatus.ClosedDate,
tblCaseInfo.DHSNo, " _
& " tlbCaseInfo.SOAHNo, tblCaseInfo.Region, tblCaseInfo.NoticeDate,
tblCaseInfo.Fieldofc, " _
& " tblCaseInfo.AppealDate, tblCaseInfo.AssignDate,
tblCaseInfo.DHSAttny, tblCaseInfo.Asstnt, " _
& " tblCaseInfo.Vendor, tblCaseInfo.Facility,
tblCaseInfo.Facility-PetAddy, tblCaseInfo.Facility-PetCity, " _
& " tblCaseInfo.Facility-PetState, tblCaseInfo.Facility-PetZip,
tblCaseInfo.Facility-PetPh, " _
& " tblCaseInfo.Facility-PetFax, tblCaseInfwner, tblCaseInfo.RepID,
tblCaseInfo.Program, " _
& " tblCaseInfo.Action, tblCaseInfo.Amt, tblCaseInfo.Rate1,
tblCaseInfo.Start1, tblCaseInfo.End1, " _
& " tblCaseInfo.Rate2, tblCaseInfo.Start2, tblCaseInfo.End2,
tblCaseInfo.Sanction, " _
& " tblCaseInfo.Surveys, tblCaseInfo.IDR, tblCaseInfo.TAC,
tblCaseInfo.ViolationDescrip, " _
& " tblCaseInfo.Comment, tblRepresentatives, tblStatus.StatusRptNotes,
tblStatus.BankruptyEntity, " _
& " tblStatus.BankruptDate, tblStatus.Bankruptcy, tblStatus.Disposition,
" _
& " tblStatus.CSAAmt, tblStatus.BoxNo, tblRegion.SUBOFC, tblRegion.PM, "
_
& " tblRegion.PMPH, tblRegion.Ext, tblRegion.Region, " _
& " FROM ((tblRepresentatives RIGHT JOIN tblCaseInfo ON
tblRepresentatives.ID = tblCaseInfo.RepID), " _
& " LEFT JOIN tblRegion ON tblCaseInfo.FieldOfc = tblRegion.ID) LEFT
JOIN tblStatus ON tblCaseInfo.DHSNo = tblStatus.DHSNo, " _
& " WHERE tblCaseInfo.CaseName LIKE " & Me.txtSearch & "" _
& " AND tblStatus.ClosedDate Is Null, " _
& " ORDER BY tblCaseInfo.CaseName; "
DoCmd.OpenForm stDocName, , , stLinkCriteria