473,383 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

form closing

Hi guys,

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_Click

Dim stDocName As String
stDocName = "reciept"
DoCmd.OpenReport 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

Nov 13 '05 #1
2 1708
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.OpenReport 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.googlegr oups.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_Click

Dim stDocName As String
stDocName = "reciept"
DoCmd.OpenReport 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

Nov 13 '05 #2
wow, great help sir.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ThunderMusic | last post by:
Hi, I'm trying to have a MSN Messenger like form/app closing behavior. When I click on the X button, I only want the form to disappear and when I double-click on the notify icon or right-click...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
2
by: Nenad Dobrilovic | last post by:
Hi, is there any way to find out how form was closed (by calling it's method Close() or by clicking on the 'close' button in control box)? Also, can I close the form in that way that Cloing/Closed...
6
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
6
by: **Developer** | last post by:
I've been looking but can't find out how in a form Closing event to know if the closing is because the form's "X" had been clicked or the main form's "X" was clicked. That is, I need to know if...
11
by: Zytan | last post by:
I have created a new form from the main form. When I close the main form with the 'x' close button, its Form.FormClosed event is run, but not the dialog's. Is this normal? It is ok /...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
19
by: rbrowning1958 | last post by:
Hello, I am confused by dispose etc. and hope someone can set me right. 1. The Dispose(Bool) the IDE generates for a form has nothing to do with IDisposable, right? 2. So when is this called?...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.