Change the query that the report draws from so it does not refer to the form
to get the invoice number. Use the WhereCondition of OpenReport to pass the
query number. That way the report is independent of the form, and so you can
close the form.
Private Sub Command18_Click ()
Dim stDocName As String
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False 'save first.
If Me.NewRecord Then
MsgBox "Select a record to print.
Else
stDocName = "receipt"
strWhere = "InvoiceID = " & Me.InvoiceID
DoCmd.OpenRepor t stDocName, acViewPreview, , strWhere
DoCmd.Close acForm, Me.Name
End If
End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"khan" <ah******@gmail .com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
I have a form called frminvoice, On this form I have a button to ptint
report or invoice where report will get invoice number from
[frminvoice]![txtInvoiceNum]. Now I want when I click print invoice
button, it should close form frminvoice. this is the code I have. but
it is not closing the form.
On Error GoTo Err_Command18_C lick
Dim stDocName As String
stDocName = "reciept"
DoCmd.OpenRepor t stDocName, acPreview
DoCmd.Close , "frmInvoice "
if I use DoCmd.Close , "frmInvoice " before open the invoice then it
cant find invoice number. can any one help plzzzzzzzzz