If Statements

  • Thread starter Thread starter Michael
  • Start date Start date
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
 
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.
 
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
 
Back
Top