If statement does not work

miguel vasquez

Registered User.
Local time
Today, 13:21
Joined
Nov 11, 2002
Messages
36
Hi Guys,

I am trying to do this small programming in VBA, but one of the below if statement is not working. The first If statement works, if I remove the second one and viceversa. If me.deptname is working.



If Me.TypeOfReport <> "Both" Then
strRPT = "'" & Me.TypeOfReport & "'"
strRPT1 = "'" & Me.TypeOfReport & "'"

ElseIf Me.TypeOfReport = "Both" Then
strRPT = "'Recovery'"
strRPT1 = "'Settlement'"


If Me.DeptName <> "All" Then
strDept = "'" & Me.DeptName & "'"

strSQL = "Select * into ReportTable from MainTable Where (type =" & strRPT & " or type =" & strRPT1 & ") and (DepartmentName =" & strDept & ")"
DoCmd.RunSQL strSQL
DoCmd.OpenTable "ReportTable", acNormal, acEdit
 
I did not want to send the whole program, but all the end if statements are there. The combination of the first if and elseif statement is the problem.
 
I used the end if after the elseif code and it works...

thanks a bunch!!!
 
Happy to help and thanks for the response, it saved me wondering if I was right.

Brian
 

Users who are viewing this thread

Back
Top Bottom