Passing Parameters

miguel vasquez

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

I am having problem with this programming, since my where condition is reading my parameters. My parameter strRPT and strDept are getting the assinged value, but my where condition is not reading them.

Please help!!!


Private Sub Command27_Click()
Dim strRpt1 As String
Dim strRpt2 As String
Dim strRpt As String
Dim strDept As String


strRpt = "'" & Me.TypeOfReport & "'"
strDept = "'" & Me.DeptName & "'"

strRpt1 = "Select * into ReportTable from MainTable"


If Me.TypeOfReport <> "Both" And Me.DeptName <> "All" And (Eval("[Forms]![MainForm]![DOSfrom] Is not Null")) And (Eval("[Forms]![MainForm]![DOSto] Is not Null")) Then
strRpt1 = strRpt1 & " Where me.typeOfReport = strRpt and Me.DeptName = strDept"
DoCmd.RunSQL strRpt1
DoCmd.OpenTable "ReportTable", acNormal, acEdit

End If
 
Code:
strRpt1 = strRpt1 & " Where "  & Me.typeOfReport & " = """ & strRpt & """ And " & Me.DeptName " & " = """ & strDept & """"
Putting variables into a string will literally interpret them as their name rather than their value. Thus you have to break open the string and concatenate it.
 
Now it works...thanks a lot SJ McAbney
 

Users who are viewing this thread

Back
Top Bottom