Thank you so much camaro for your help, I found that my problem was
because I
had OrderID in the form and OrderId in the Subform, I have remove
OrderID
from subform and it's working fine righ now..
anyway I want to thank you all your attention to my question.
Best Regards and God bless you.
Thanks.
(e-mail address removed)
:
Oops. You mentioned "has the same name of text box" and I
mistranslated
that
to mean the same name as I had given the text box, not the text box
with
the
same name as your primary key. Try:
rpt.RecordSource = "SELECT * " & _
"FROM [Orders Query Invoice] " & _
"WHERE (OrderID = " & Me!OrderID.Value & ");"
Sorry for any confusion. And if you want to avoid bugs in the future,
don't
accept the default names that Access gives for the controls that are
going to
be referenced either in VBA code, as shown above, or as a property.
Rename
these controls to something like txtOrderID, which indicates it's a
text
box
displaying the OrderID field.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a
message
will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the
question
"Did this post answer your question?" at the bottom of the message,
which
adds your question and the answers to the database of answers.
Remember
that
questions answered the quickest are often from those who have a
history
of
rewarding the contributors who have taken the time to answer questions
correctly.
:
could you help me to fx this
Sure. You have illegal characters in the name of the query. Spaces
aren't
allowed. However, Jet often lets one "fix" these illegal characters
if
one
puts brackets around a multiple-worded name. For example:
rpt.RecordSource = "SELECT * " & _
"FROM [Orders Query Invoice] " & _
"WHERE (OrderID = " & Me!txtOrderID.Value & ");"
There's no guarantee that illegal characters that are bracketed will
work in
every situation. Only use alphanumeric characters and the
underscore
character when naming any object (that includes tables and fields),
procedure, or variable, and you will avoid many, many bugs.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a
message
will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the
question
"Did this post answer your question?" at the bottom of the message,
which
adds your question and the answers to the database of answers.
Remember that
questions answered the quickest are often from those who have a
history
of
rewarding the contributors who have taken the time to answer
questions
correctly.
:
Hi camaro...I used your code but appear an error message that
says:
Error #3131
Syntax error in FROM clause
my query name is:Orders Query Invoice
my form Name is "Orders" where I put the button
my primary key is OrderID and it has the same name of text box.
could you help me to fx this, I'm sure it work but I have a little
problem.
Thanks for your help..
Ldiaz
:
Make a copy of your "Orders" report and name this copy
"rptSingleOrder"
because you are going to be making modifications to it
programmatically, and
you'll probably want to keep the original. Next, look at the
rptSingleOrder's Record Source Property to find the query or
table
that's
used as the record source. In the example below, I've used
qryOrders, but
you'll need to replace this name with your report's Record
Source
Property.
Next, create a button on your Orders form and paste the
following
code in the
form's module:
Private Sub EMailRptBtn_Click()
On Error GoTo ErrHandler
Dim rpt As Report
Dim sRptName As String
Dim sMsg As String
Dim stdomail As String
sRptName = "rptSingleOrder"
sMsg = "Please confirm if this Order Quotation is correct
with
" & _
"Product Name, Descripción & price!!"
stdomail = Me![SupplierID].Column(2) 'This column has the
e-mail address
DoCmd.OpenReport sRptName, acViewDesign
Set rpt = Reports(sRptName)
rpt.RecordSource = "SELECT * " & _
"FROM qryOrders " & _
"WHERE (OrderID = " & Me!txtOrderID.Value & ");"
DoCmd.Close acReport, sRptName, acSaveYes
DoCmd.SendObject acSendReport, sRptName, acFormatSNP, _
stdomail, , , "Order Quotation", sMsg, False
CleanUp:
Set rpt = Nothing
Exit Sub
ErrHandler:
If (Err.Number <> 2501) Then ' User didn't cancel
E-Mail.
MsgBox "Error in EMailRptBtn_Click( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf &
Err.Description
End If
Err.Clear
GoTo CleanUp
End Sub ' EMailRptBtn_Click( )
. . . where EMailRptBtn is the name of the button,
rptSingleOrder
is the
name of the report that gets modified and sent as a snapshot to
the
recipient, SupplierID is the combo box that holds the E-Mail
address,
qryOrders is the data source for the orders, OrderID is the
primary
key for
the data source, and txtOrderID is the text box that displays
the
OrderID.
Save and compile the code, then return to the form and open it
in
Form View.
Select the record to send the report to the recipient on the
form,
then
select the EMailRptBtn to send it off without editing it. If
you
want to
edit the E-mail before sending it, then change the last argument
in
the
SendObject method to TRUE. If you want a different format than
the
snapshot
format, then change acFormatSNP to a different format.
And remember that SendObject can be buggy, especially when used
in
loops.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a
message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to
the
question
"Did this post answer your question?" at the bottom of the
message,
which
adds your question and the answers to the database of answers.
Remember that
questions answered the quickest are often from those who have a
history of
rewarding the contributors who have taken the time to answer
questions
correctly.
:
Hi all..
I want to send a report but this function pull all Orders
reports
and I want
just one accordings the Orders Form is opened,
I have something similary in the Print Function to print the
same
report,
but with this I don't have the problem because it's filtered
by a
Query with
criteria, but to send individual Orders reports , I don't know
how? Could
anybody help me on this please.
Thanks.
Ldiaz
""""here is the code that I have....
____________________________________________________________
Private Sub mail_Click()
On Error GoTo Err_mail_Click
Dim stDocName As String
Dim stdomail As String
stDocName = "Orders" 'Report name
stdomail = Me![SupplierID].Column(2) 'This column has the
e-mail address
DoCmd.SendObject acReport, stDocName, , stdomail, , ,
"Order
Quotation",
"Please confirm if this Order Quotation is correct with
Product
Name,Descripción & price!!"
Exit_mail_Click:
Exit Sub
Err_mail_Click:
MsgBox Err.Description
Resume Exit_mail_Click
End Sub
_______________________________________________________