Hi all,
I have an SQL statement that is giving me some trouble. I've had to re-write it from a working piece of code as I discovered that when the I was opening a new record I got an error. Having written the SQL and checked the it in a query I thought it would work but, transfering it to code I have an error.
Can any one dee teh problem? or has anyone sufferd the same problem and know how to cure it?
Thanks for any replies
Lex
I get the error
'error 3061: Too few parameters. Expected 2'
This is the code, I've checked the SQl in a query and it runs fine. I'm stumped as to what the problem could be.
I have an SQL statement that is giving me some trouble. I've had to re-write it from a working piece of code as I discovered that when the I was opening a new record I got an error. Having written the SQL and checked the it in a query I thought it would work but, transfering it to code I have an error.
Can any one dee teh problem? or has anyone sufferd the same problem and know how to cure it?
Thanks for any replies
Lex
I get the error
'error 3061: Too few parameters. Expected 2'
This is the code, I've checked the SQl in a query and it runs fine. I'm stumped as to what the problem could be.
Code:
Private Sub Form_Open(Cancel As Integer)
Dim MySQL As String,Dim rs As DAO.Recordset
Dim pfix As String
Dim MyForm As String
pfix = "NA"
MySQL = "SELECT IIf(IsNull(ProjectDetails!ProjectType)," & pfix & ",[ProjectDetails]![ProjectType]) AS ProjectType1, ProjectDetails.ProjectDetailsID" & _
" FROM ProjectDetails" & _
" GROUP BY IIf(IsNull([ProjectDetails]![ProjectType])," & pfix & ",[ProjectDetails]![ProjectType]), ProjectDetails.ProjectDetailsID" & _
" HAVING (((ProjectDetails.ProjectDetailsID)=[Forms]![TeamMember]![ProjectDetailsID]));"
Set rs = CurrentDb.OpenRecordset(MySQL)
If Not IsNull(rs!ProjectType) Then
pfix = rs!ProjectType
End If
rs.Close
Set rs = Nothing
If pfix = "Community" Then
prefix = "CGP"
ElseIf pfix = "Social" Then
prefix = "SEB"
Else
prefix = ""
End If
End Sub