Problem with Code

G

Guest

I have an unbound textbox on my form, that I would like to use to search for
a borrowers name on the form. There could be several names that could match
or the names could be empty... I have the forllosing after event and its
giving me an error on this line rs.FindFirst "[BorName] ='" &
Str(Nz(Me![Combo147], 0)) & "'"
Anyw reason as to why this s happening?


Private Sub Combo147_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[BorName] ='" & Str(Nz(Me![Combo147], 0)) & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
If Len(Me!Combo147.Column(1)) = 0 Then
DoCmd.ShowAllRecords
Else
DoCmd.ApplyFilter , "[BorName] =
[Forms]![frmCallTracking]![Combo147] "
End If

End Sub
 
B

Brendan Reynolds

What error?

You might want to use CStr rather than Str. Str puts a leading space in
front of positive numbers, while CStr doesn't. The example below illustrates
the difference ...

? "|" & Str(0) & "|"
| 0|
? "|" & CStr(0) & "|"
|0|

I'm not sure that this has anything to do with your error, but it might
cause incorrect results.
 
G

Guest

You are a genius, that worked. Thanks alot!

Another quick question, I have null values but when I click on the row in my
combox that is empty , it does not filter for the records that contain
borrowers names that are missing.....


Brendan Reynolds said:
What error?

You might want to use CStr rather than Str. Str puts a leading space in
front of positive numbers, while CStr doesn't. The example below illustrates
the difference ...

? "|" & Str(0) & "|"
| 0|
? "|" & CStr(0) & "|"
|0|

I'm not sure that this has anything to do with your error, but it might
cause incorrect results.

--
Brendan Reynolds
Access MVP


JOM said:
I have an unbound textbox on my form, that I would like to use to search
for
a borrowers name on the form. There could be several names that could
match
or the names could be empty... I have the forllosing after event and its
giving me an error on this line rs.FindFirst "[BorName] ='" &
Str(Nz(Me![Combo147], 0)) & "'"
Anyw reason as to why this s happening?


Private Sub Combo147_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[BorName] ='" & Str(Nz(Me![Combo147], 0)) & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
If Len(Me!Combo147.Column(1)) = 0 Then
DoCmd.ShowAllRecords
Else
DoCmd.ApplyFilter , "[BorName] =
[Forms]![frmCallTracking]![Combo147] "
End If

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