Wednesday, March 28, 2012

please help fix this statement

im using an access project file now and no longer a mdb file.

i used to prompt a user for the first and last name of the patient they were looking for using this statement like [forms]![main]![text0] & "*"
and like [forms]![main]![text2] & "*" then it would promt them to enter in a last name and a first name but if they only entered a last name and left the first name prompt empty it would give them all the last name they had entered .

now im on sql as my backend and i got my query working except
if i dont type anything in on the second prompt i get no records.

how can i fix this because the user doesnt always no the first name and would like to sort through the records by just the last.

my current statement that works as long as you fill in both prompts is a follows.

SELECT tblpatientinfo.*
FROM tblpatientinfo
WHERE (lname LIKE @.LastName + '%') AND (fname LIKE @.firstname + '%')
ORDER BY chartnumberSELECT tblpatientinfo.*
FROM tblpatientinfo
WHERE (lname LIKE isnull(@.LastName,'') + '%') AND (fname LIKE isnull(@.firstname,'') + '%')
ORDER BY chartnumber|||Originally posted by Enigma
SELECT tblpatientinfo.*
FROM tblpatientinfo
WHERE (lname LIKE isnull(@.LastName,'') + '%') AND (fname LIKE isnull(@.firstname,'') + '%')
ORDER BY chartnumber

thank you very much worked great , im just having a hard time with the new syntax at least the vb codes i wrote still work.sql

No comments:

Post a Comment