Open report and close form

  • Thread starter Thread starter Stefan
  • Start date Start date
S

Stefan

I am opening a report from a form using the criteria on
the form for the filter.

I have the following code

Dim stPatient As String
stPatient = "[ChartNumberChoice]"

If IsNull(Me.ChartNumberChoice) = True Then
DoCmd.Close
DoCmd.OpenReport stDocName, acPreview

Else
'DoCmd.Close
DoCmd.OpenReport stDocName,acViewPreview, "", "[Chart
Number]=[Forms]![frm_OpenCopay]![ChartNumberChoice]",
acNormal
End If

If I leave the DoCmd.Close after the else
Chartnumberchoice loses its value and the filter does not
work. I tried to assign ChartNumberChoice to the variable
stPatient but I couldn't get that to work.

How can I close the form without losing the value in
ChartNumberChoice for filtering

Thanks in Advance
 
-----Original Message-----
try replacing
DoCmd.Close Me.Name, acSaveNo
with

DoCmd.Close acForm, "formname", acSaveNo

HTH
Al
STefan said:
I got a type mismatch error. What is Me.name?

frm_OpenCoPay is an unbound form, this is what I would
like to close when the report opens. and
ChartNumberChoice is an unbound lookup(combo box) field
which returns an alpha numeric value from a table with
patient information

Chart Number is the field on the report that I am
filtering for.



-----Original Message-----
Try

****Untested****
Dim stPatient As String
stPatient = "[ChartNumberChoice]"

If IsNull(Me.ChartNumberChoice) = True Then
DoCmd.OpenReport stDocName, acPreview

Else
DoCmd.OpenReport stDocName,acViewPreview, , _
"[Chart Number]= " & Me.ChartNumberChoice, _
acNormal
End If
DoEvents
DoCmd.Close Me.Name, acSaveNo
****

I assumed [ChartNumberChoice] is on the current Form
[frm_OpenCopay] and it is bound to a Numeric Field
(corresponding to the Field???) [Chart Number]. I also
assumed the code is executed in the context of the Form
[frm_OpenCopay] which is the Form you want to close.

HTH
Van T. Dinh
MVP (Access)




-----Original Message-----
I am opening a report from a form using the criteria on
the form for the filter.

I have the following code

Dim stPatient As String
stPatient = "[ChartNumberChoice]"

If IsNull(Me.ChartNumberChoice) = True Then
DoCmd.Close
DoCmd.OpenReport stDocName, acPreview

Else
'DoCmd.Close
DoCmd.OpenReport
stDocName,acViewPreview, "", "[Chart
Number]=[Forms]![frm_OpenCopay]![ChartNumberChoice]",
acNormal
End If

If I leave the DoCmd.Close after the else
Chartnumberchoice loses its value and the filter does not
work. I tried to assign ChartNumberChoice to the
variable
stPatient but I couldn't get that to work.

How can I close the form without losing the value in
ChartNumberChoice for filtering

Thanks in Advance
.

.


.
 
Back
Top