searh for record.

  • Thread starter sheniece via AccessMonster.com
  • 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
 
J

John W. Vinson

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]
 
S

sheniece via AccessMonster.com

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]
 

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