multiple link criteria in sql statement

  • Thread starter Lori2836 via AccessMonster.com
  • Start date
L

Lori2836 via AccessMonster.com

Can you help? The scenario: Click on ID # in a subform and the form opens
with the information tied to the ID, by the Item Desc. What I want to know
is........how do you add to the criteria? I'd like to use Item Desc AND
Customer in the "stLinkCriteria", but not sure how to code it.

Private Sub ID_Click()

On Error GoTo Err_ID_Click

Dim stDocName, stLinkCriteria As String

stLinkCriteria = "[Item Desc]='" & [Item Desc] & "' "

stDocName = "Face Sheet to be reviewed"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit

Exit_ID_Click:
Exit Sub

Err_ID_Click:
MsgBox Err.Description
Resume Exit_ID_Click
End Sub


Thanks for any help!
 
K

kingston via AccessMonster.com

If I understand you correctly, you just need to extend your existing criteria:


stLinkCriteria = "[Item Desc]='" & [Item Desc] & "' AND [Customer]='" &
[Customer] & "'"

Check for Nulls first in an If statement:

If IsNull([Item Desc]) AND IsNull([Customer]) Then
criteria = nothing
ElseIf IsNull([Item Desc]) Then
criteria = customer-based only
...
Can you help? The scenario: Click on ID # in a subform and the form opens
with the information tied to the ID, by the Item Desc. What I want to know
is........how do you add to the criteria? I'd like to use Item Desc AND
Customer in the "stLinkCriteria", but not sure how to code it.

Private Sub ID_Click()

On Error GoTo Err_ID_Click

Dim stDocName, stLinkCriteria As String

stLinkCriteria = "[Item Desc]='" & [Item Desc] & "' "

stDocName = "Face Sheet to be reviewed"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit

Exit_ID_Click:
Exit Sub

Err_ID_Click:
MsgBox Err.Description
Resume Exit_ID_Click
End Sub

Thanks for any help!
 

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