Returning multiple records

G

Guest

I have a form that is called "Customer Search", this box filters the records
in my database for any matches to the first name, last name, or social sec
num., in any combination. If a match is found it closes the search box and
opens a payment form. If no match is found it closes the search box and
returns message stating that the "customer does not exist". This works great
until I have more than one instance of the information entered, it closes the
search box and returns the message "customer does not exist". I have
provided my code below.

Public Function getCustomerData() As String

Dim whereString As String

DoCmd.OpenForm "Frm_SearchCustomer", , , , , acDialog

If custLastName = "" And custFirstName = "" And custSS = "" Then
MsgBox "No info entered."
Else ' something specified

If custLastName <> "" Then 'last name provided
whereString = "LastName='" & custLastName & "'"
End If

If custFirstName <> "" Then 'first name provided
whereString = whereString & " AND FirstName='" & custFirstName &
"'"
End If

If custSS <> "" Then 'ss provided
whereString = whereString & " AND SocialSecNumber='" & custSS &
"'"
End If

If Left(whereString, 5) = " AND " Then
'drop leading 'and'
whereString = Right(whereString, Len(whereString) - 5)
End If

If Len(whereString) > 0 Then
'whereString = " WHERE (" & whereString & ");"
End If

getCustomerData = whereString

Any sugestions would be greatly appreciated.
Thank you
 
D

David Lloyd

Sarah:

If I understand your issue correctly, it would be helpful to see the portion
of your code where the records are retrieved and the search form is closed.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.



I have a form that is called "Customer Search", this box filters the records
in my database for any matches to the first name, last name, or social sec
num., in any combination. If a match is found it closes the search box and
opens a payment form. If no match is found it closes the search box and
returns message stating that the "customer does not exist". This works great
until I have more than one instance of the information entered, it closes
the
search box and returns the message "customer does not exist". I have
provided my code below.

Public Function getCustomerData() As String

Dim whereString As String

DoCmd.OpenForm "Frm_SearchCustomer", , , , , acDialog

If custLastName = "" And custFirstName = "" And custSS = "" Then
MsgBox "No info entered."
Else ' something specified

If custLastName <> "" Then 'last name provided
whereString = "LastName='" & custLastName & "'"
End If

If custFirstName <> "" Then 'first name provided
whereString = whereString & " AND FirstName='" & custFirstName &
"'"
End If

If custSS <> "" Then 'ss provided
whereString = whereString & " AND SocialSecNumber='" & custSS &
"'"
End If

If Left(whereString, 5) = " AND " Then
'drop leading 'and'
whereString = Right(whereString, Len(whereString) - 5)
End If

If Len(whereString) > 0 Then
'whereString = " WHERE (" & whereString & ");"
End If

getCustomerData = whereString

Any sugestions would be greatly appreciated.
Thank you
 

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

Similar Threads

Code Issue 1
Code for List Boxes 17
List Box and Query 3
List Box Coding Problem 1
Wrong Data Type 2
Search function 1
Message Box to Display a count of Records 3
List Box Search 3

Top