searh for record.

  • Thread starter Thread starter sheniece via AccessMonster.com
  • Start date Start date
S

sheniece via AccessMonster.com

I have a unbound text box on a form, the user is suppose to enter a social
security number so he/she can find the person it belongs to, but for some
reason it's not working, the code is below.

Dim strSearch As String

strSearch = "[SSN] = " & Nz(Me![tbxSSNSearch].Value)


With Me.RecordsetClone
.FindFirst strSearch
If .NoMatch Then
MsgBox "Patient not found"
Else
Me.Bookmark = .Bookmark
End If
End With
 
I have a unbound text box on a form, the user is suppose to enter a social
security number so he/she can find the person it belongs to, but for some
reason it's not working, the code is below.

Dim strSearch As String

strSearch = "[SSN] = " & Nz(Me![tbxSSNSearch].Value)


With Me.RecordsetClone
.FindFirst strSearch
If .NoMatch Then
MsgBox "Patient not found"
Else
Me.Bookmark = .Bookmark
End If
End With

If SSN is a Text field you need some syntactical quotemarks:

strSearch = "[SSN] = '" & Nz(Me![tbxSSNSearch]) & "'"

The .Value operand isn't needed. Of course if tbxSSNSearch is NULL it will
search for an empty string in SSN (which will fail, but I'd guess you would
want it to do so).


John W. Vinson [MVP]
 
Thank you John, it worked like a charm..
I have a unbound text box on a form, the user is suppose to enter a social
security number so he/she can find the person it belongs to, but for some
[quoted text clipped - 13 lines]
End If
End With

If SSN is a Text field you need some syntactical quotemarks:

strSearch = "[SSN] = '" & Nz(Me![tbxSSNSearch]) & "'"

The .Value operand isn't needed. Of course if tbxSSNSearch is NULL it will
search for an empty string in SSN (which will fail, but I'd guess you would
want it to do so).

John W. Vinson [MVP]
 
Back
Top