I have a form where i hve two unbound text boxes, and one search button. One box is keywork and the other is presenters name, if i put something in keywork only i get the proper results and if i put something in presenters name i get proper results but if i put something in both i gets no results but i wanted both too work at the same time. Here is the code i have for the button anyone see anything wrong?
Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As String
Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!
Or try our Ask An Expert service to answer any of your questions!
An empty text box contains a Null value. a VB text string cannot be null - it's equivelent is a zero length string ("").
if you change the variable assignments to:
test = nz(Me![txtKeyword])
test1 = nz(Me![txtPresentersname])
the nz function changes a null to the default value for a data type (in this case a zero length string). Worth looking up in help as it can be very useful, both as preventing errors like this and also simplifying your code (without it you would use a lot more if statements).
This should do what you want, so long as your PresentersName and Keyword fields contain values for all records.