Option of returning all records using stLinkCriteria

G

Guest

I have the following code to open a form, which works fine. I need to add
the option to leave the model blank and return all models with the selected
part number. Can someone help me add this code? Thanks.

stLinkCriteria = "[New Part Name]=" & "'" & Me![SearchName] & "'"
stLinkCriteria = stLinkCriteria & "AND [Model#]=" & "'" & Me![Model] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
A

Albert D.Kallal

try:

stLinkCriteria = "[New Part Name] = " & "'" & Me!SearchName & "'"

if isnull(me!Model) = false then
stLinkCriteria = stLinkCriteria & " AND Model# = " & "'" & Me!Model &
"'"
end if

DoCmd.OpenForm stDocName, , , stLinkCriteria
 

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