Runtime Error

O

OEB

I am getting a runtime error:

Dim qdfAction As DAO.QueryDef
Dim prmCurr As DAO.Parameter

Set qdfAction = CurrentDb.QueryDefs("qryAppendRTEHistory")
For Each prmCurr In qdfAction.Parameters
prmCurr.value = Eval(prmCurr.Name)
If prmCurr.Name = "[Enter Division: Retail-1, Institutional-2,
Corporate-3]" Then
prmCurr.value = [Forms].[RTEsbyRTE].[Division]
End If
Next prmCurr
qdfAction.Execute dbFailOnError

What's wrong with this code, specifically the if statement? When I debug
the prmCurr.Name was equal the string.
 
M

Marshall Barton

OEB said:
I am getting a runtime error:

Dim qdfAction As DAO.QueryDef
Dim prmCurr As DAO.Parameter

Set qdfAction = CurrentDb.QueryDefs("qryAppendRTEHistory")
For Each prmCurr In qdfAction.Parameters
prmCurr.value = Eval(prmCurr.Name)
If prmCurr.Name = "[Enter Division: Retail-1, Institutional-2,
Corporate-3]" Then
prmCurr.value = [Forms].[RTEsbyRTE].[Division]
End If
Next prmCurr
qdfAction.Execute dbFailOnError

What's wrong with this code, specifically the if statement? When I debug
the prmCurr.Name was equal the string.


You need to skip that one parameter with Eval.

For Each prmCurr In qdfAction.Parameters
If prmCurr.Name = "[Enter Division: Retail-1,
Institutional-2, Corporate-3]" Then
prmCurr.value = [Forms].[RTEsbyRTE].[Division]
Else
prmCurr.value = Eval(prmCurr.Name)
End If
Next prmCurr
 

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