If Statements

M

Michael

I need to create an if statement that will first determine whether the
contact type is a client or a vendor. Then, it needs to open a
particular form based on criteria for each of the vendors & clients
sub types. Here is what I came up with so far but obviously it
doesn't work. Can someone show me what I'm missing?

Private Sub ContactID_DblClick(Cancel As Integer)
On Error GoTo Err_ContactID_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

If Me![ContactType] = "Vendor" Then
If Me![VendorType] = "Labor Vendor" Then
stDocName = "FRM_Vendors-Labor-Direct"
ElseIf Me![VendorType] = "Resource Vendor" Then
stDocName = "frm_vendorsResource"
Else: stDocName = "FRM_VendorsAll"
End If

stLinkCriteria = "[vendorID]=" & Me![VendorID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If Me![ContactType] = "Client" Then
If Me![ContactSubType] = "Clients-Contract" Then
stDocName = "FRM_Clients_Contract"
ElseIf Me![ContactSubType] = "Clients-Direct" Then
stDocName = "Frm_Clients_Direct"
Else: stDocName = "FRM_Clients_Indirect"
End If

stLinkCriteria = "[ContactID]=" & Me![ContactID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ContactID_DblClick:
Exit Sub

Err_ContactID_DblClick:
MsgBox Err.Description
Resume Exit_ContactID_DblClick
End Sub
 
M

Michael

Perfect! I knew that's what it was but I didn't know where to put all
the EndIF's

Thanks a million! My life is now officially easier and more
productive thanks to you.
 
M

Michael

Here is my finished product if anyone wants it for reference:

Private Sub ContactID_DblClick(Cancel As Integer)
If Me![ContactType] = "Vendor" Then
If Me![ContactSubType] = "Vendors-Direct" Then
stDocName = "FRM_Vendors-Labor-Direct"
ElseIf Me![ContactSubType] = "Resource Vendor" Then
stDocName = "frm_vendorsResource"
ElseIf Me![ContactSubType] = "Employee" Then
stDocName = "frm_vendorsEmployee"
Else
stDocName = "FRM_VendorsAll"
stLinkCriteria = "[vendorID]=" & Me![ContactID]
End If

ElseIf Me![ContactType] = "Client" Then
If Me![ContactSubType] = "Clients-Contract" Then
stDocName = "FRM_Clients_Contract"
ElseIf Me![ContactSubType] = "Clients-Direct" Then
stDocName = "Frm_Clients_Direct"
Else
stDocName = "FRM_Clients_Indirect"
End If
stLinkCriteria = "[ClientID]=" & Me![ContactID]
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
 

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