filter fail after FE copied to server

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear all,

I have a FE subform that open a report using the following code with filter:

Private Sub btnDevOrder_Click()
On Error GoTo Err_btnDevOrder_Click

Dim stDocName As String

stDocName = "rptDO"

DoCmd.OpenReport stDocName, acPreview, , "DevRequestNo=" &
"forms!frmDevelopment.sfmDevItem!DevRequestNo"



Exit_btnDevOrder_Click:
Exit Sub

Err_btnDevOrder_Click:
MsgBox Err.Description
Resume Exit_btnDevOrder_Click

End Sub

It runs well until I copied the FE to my server. The filter no longer works
and cannot pass the parameter to my query.

Any idea why the filter would fail after FE transfer?

Many thanks.

Newland
 
Concatenate the value from the control in the subform into the
WhereCondition argument. The quote you have are not doing that.

You might find it helps to make this a seprate string, so you can
Debug.Print it to verify it is correct.

Dim strWhere As String
strWhere = "DevRequestNo=" &
Forms!frmDevelopment.sfmDevItem.Form!DevRequestNo
Debug.Print strWhere
DoCmd.OpenReport stDocName, acPreview, , strWhere

If this code is in the subform's module, you could just use:
strWhere = "DevRequestNo=" & Me.DevRequestNo

If DevRequestNo is a Text type field (not a Number type field), you need
extra quotes:
strWhere = "DevRequestNo=""" &
Forms!frmDevelopment.sfmDevItem.Form!DevRequestNo & """"

Other possibilities include making sure that any edits are saved before you
open report:
If Me.Dirty Then Me.Dirty = False
and also checking that the form has a record (so DevRequestNo is not null.)
 
Thanks I will try it.

But any idea why moving the file would results in failing? I am so worried
about deploying to other servers but cannot spot the reason ...
 
It is now working. Many Many Thanks!!

ecyyn said:
Thanks I will try it.

But any idea why moving the file would results in failing? I am so worried
about deploying to other servers but cannot spot the reason ...
 

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

Back
Top