Group:  Microsoft Access ยป microsoft.public.access.gettingstarted
Thread: Run report on a forms I'm currently editing

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Run report on a forms I'm currently editing
Dj 31.07.2006 19:12:02
My Form has a button which unts a Macro which prints a Report which is run
off of a Query whose criteria is [Forms]![My Form]![ID].

After having no luck with it displaying the current record I was editing,
through testing and debugging, I was able to determine that once the current
record I'm in is in edit mode (you know, with the little pencel icon), my
report won't print the changes I put in until I've left that record and go
back to it without entering edit mode.

My true desire is to run the report of a brand new record I just added, but
again, nothing will show in the report until I've left out of edit mode and
point back to the record without going into edit mode.

Can anyone tell me what I can do, possibly to my Macro, to get my record out
of edit mode right before I run the report so that I get my latest chagnges
in the report?

Thx, Dj
Re: Run report on a forms I'm currently editing
"Rick B" <Anonymous> 31.07.2006 19:17:49
Not sure how to do this with a macro. But, using a button and code, you'd
do something similar to the following...

Button to print specific record
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.

Me.Dirty = False

End If

If Me.NewRecord Then 'Check there is a record to print

MsgBox "Select a record to print"

Else

strWhere = "[ID] = " & Me.[ID]

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

End If

End Sub



Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with
acViewNormal.



See also: http://allenbrowne.com/casu-15.html




--
Rick B



"Dj" <Dj[ at ]discussions.microsoft.com> wrote in message
news:69789F43-C18F-4958-99CE-969936A51F33[ at ]microsoft.com...
[Quoted Text]
> My Form has a button which unts a Macro which prints a Report which is run
> off of a Query whose criteria is [Forms]![My Form]![ID].
>
> After having no luck with it displaying the current record I was editing,
> through testing and debugging, I was able to determine that once the
> current
> record I'm in is in edit mode (you know, with the little pencel icon), my
> report won't print the changes I put in until I've left that record and go
> back to it without entering edit mode.
>
> My true desire is to run the report of a brand new record I just added,
> but
> again, nothing will show in the report until I've left out of edit mode
> and
> point back to the record without going into edit mode.
>
> Can anyone tell me what I can do, possibly to my Macro, to get my record
> out
> of edit mode right before I run the report so that I get my latest
> chagnges
> in the report?
>
> Thx, Dj


RE: Run report on a forms I'm currently editing
Dj 31.07.2006 20:15:01
Never having worked with the Dirty Event, I was reading up on it in help menu
near the bottom it references "Click Save Record on the Records Menu". I
actually think that would help too. However, I don't know where to find the
Records Menu. It is so simple I'm overlooking it? Thanks!

"Dj" wrote:

[Quoted Text]
> My Form has a button which unts a Macro which prints a Report which is run
> off of a Query whose criteria is [Forms]![My Form]![ID].
>
> After having no luck with it displaying the current record I was editing,
> through testing and debugging, I was able to determine that once the current
> record I'm in is in edit mode (you know, with the little pencel icon), my
> report won't print the changes I put in until I've left that record and go
> back to it without entering edit mode.
>
> My true desire is to run the report of a brand new record I just added, but
> again, nothing will show in the report until I've left out of edit mode and
> point back to the record without going into edit mode.
>
> Can anyone tell me what I can do, possibly to my Macro, to get my record out
> of edit mode right before I run the report so that I get my latest chagnges
> in the report?
>
> Thx, Dj
Re: Run report on a forms I'm currently editing
"Rick B" <Anonymous> 31.07.2006 20:22:14
Dj, the code I posted will save a dirty record. No need to know where a
particular menu item is. Just copy the code and modify the names to match
your report name, field names, etc.

--
Rick B



"Dj" <Dj[ at ]discussions.microsoft.com> wrote in message
news:AA351A26-0509-40A5-8408-E8CFC8AEFA42[ at ]microsoft.com...
[Quoted Text]
> Never having worked with the Dirty Event, I was reading up on it in help
> menu
> near the bottom it references "Click Save Record on the Records Menu". I
> actually think that would help too. However, I don't know where to find
> the
> Records Menu. It is so simple I'm overlooking it? Thanks!
>
> "Dj" wrote:
>
>> My Form has a button which unts a Macro which prints a Report which is
>> run
>> off of a Query whose criteria is [Forms]![My Form]![ID].
>>
>> After having no luck with it displaying the current record I was editing,
>> through testing and debugging, I was able to determine that once the
>> current
>> record I'm in is in edit mode (you know, with the little pencel icon), my
>> report won't print the changes I put in until I've left that record and
>> go
>> back to it without entering edit mode.
>>
>> My true desire is to run the report of a brand new record I just added,
>> but
>> again, nothing will show in the report until I've left out of edit mode
>> and
>> point back to the record without going into edit mode.
>>
>> Can anyone tell me what I can do, possibly to my Macro, to get my record
>> out
>> of edit mode right before I run the report so that I get my latest
>> chagnges
>> in the report?
>>
>> Thx, Dj


Re: Run report on a forms I'm currently editing
fredg <fgutkind[ at ]example.invalid> 31.07.2006 20:28:13
On Mon, 31 Jul 2006 12:12:02 -0700, Dj wrote:

[Quoted Text]
> My Form has a button which unts a Macro which prints a Report which is run
> off of a Query whose criteria is [Forms]![My Form]![ID].
>
> After having no luck with it displaying the current record I was editing,
> through testing and debugging, I was able to determine that once the current
> record I'm in is in edit mode (you know, with the little pencel icon), my
> report won't print the changes I put in until I've left that record and go
> back to it without entering edit mode.
>
> My true desire is to run the report of a brand new record I just added, but
> again, nothing will show in the report until I've left out of edit mode and
> point back to the record without going into edit mode.
>
> Can anyone tell me what I can do, possibly to my Macro, to get my record out
> of edit mode right before I run the report so that I get my latest chagnges
> in the report?
>
> Thx, Dj

Do is using code. It's very simple.
On the Command Button's click event line, write
[Event Procedure]

Then click on the little button with 3 dots that appears on that line.

The code window will open, with the cursor flashing between 2 already
written lines of code.
Between those 2 lines of code write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acViewPreview, , "[ID] = " & Me![ID]

The above assumes the [ID] field is a Number datatype.

If [ID] is Text datatype, use:
DoCmd.OpenReport "ReportName", acViewPreview, , "[ID] = '" & Me![ID] &
"'"

Save the changes.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net