Why does code Loop

When I click on a command button to show a report I have a break point on the 
command_click.  Upon clicking the command button it opens a report.

    DoCmd.OpenReport stDocName, acPreview

As I step through the code I noticed that as I come to the end sub I expect 
the code to stop.  But It starts back at the report_activate event and loops 
through the code again then opens the form.

Thanks in advance for you help
0
Utf
5/25/2010 10:00:01 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

2 Replies
1147 Views

Similar Articles

[PageSpeed] 55

If I had to take a guess, opening a report causes more than one event to 
fire, and one of those events calls another...

Does this sound like what's happening?

If you'll post the complete code that you're stepping through, maybe someone 
here can spot something else...

Regards

Jeff Boyce
Microsoft Access MVP

-- 
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"Which1" <Which1@discussions.microsoft.com> wrote in message 
news:3C574536-F582-4924-8DCA-C088E7371F6B@microsoft.com...
> When I click on a command button to show a report I have a break point on 
> the
> command_click.  Upon clicking the command button it opens a report.
>
>    DoCmd.OpenReport stDocName, acPreview
>
> As I step through the code I noticed that as I come to the end sub I 
> expect
> the code to stop.  But It starts back at the report_activate event and 
> loops
> through the code again then opens the form.
>
> Thanks in advance for you help 


0
Jeff
5/25/2010 10:57:10 PM
Thanks Jeff, 

I put in a msgbox and ran the code without stepping thourgh and it ran fine.

"Jeff Boyce" wrote:

> If I had to take a guess, opening a report causes more than one event to 
> fire, and one of those events calls another...
> 
> Does this sound like what's happening?
> 
> If you'll post the complete code that you're stepping through, maybe someone 
> here can spot something else...
> 
> Regards
> 
> Jeff Boyce
> Microsoft Access MVP
> 
> -- 
> Disclaimer: This author may have received products and services mentioned
> in this post. Mention and/or description of a product or service herein
> does not constitute endorsement thereof.
> 
> Any code or pseudocode included in this post is offered "as is", with no
> guarantee as to suitability.
> 
> You can thank the FTC of the USA for making this disclaimer
> possible/necessary.
> 
> "Which1" <Which1@discussions.microsoft.com> wrote in message 
> news:3C574536-F582-4924-8DCA-C088E7371F6B@microsoft.com...
> > When I click on a command button to show a report I have a break point on 
> > the
> > command_click.  Upon clicking the command button it opens a report.
> >
> >    DoCmd.OpenReport stDocName, acPreview
> >
> > As I step through the code I noticed that as I come to the end sub I 
> > expect
> > the code to stop.  But It starts back at the report_activate event and 
> > loops
> > through the code again then opens the form.
> >
> > Thanks in advance for you help 
> 
> 
> .
> 
0
Utf
6/4/2010 9:33:22 PM
Reply:

Similar Artilces:

Exit code question
When running an MFC VC6++ app in debug, after the program terminates I see the following information in the debug window: The thread 0x75C has exited with code 2 (0x2). The thread 0xAF8 has exited with code 2 (0x2). The thread 0x9D0 has exited with code 2 (0x2). What does code 2 mean? Thanks, Jack it means a 2 was supplied as the argument for exitthread(). to find out more you have to figure out what those threads are and under what conditions they exit with code 2. "Microsoft" <jack@dxbase.com> wrote in message news:upr2BEuBFHA.3120@TK2MSFTNGP12.phx.gbl... > When r...

VBA code for a timeline chart (lookalike)
I posted this in the "Charting" newsgroup but, since it is not truly a chart, I thought I'd also post it here: As I stated in my previous post, my VBA skills are rudimentary but I ordered J. Walkenbach's "VBA for Excel" and I am hoping to learn a little more over the next few weeks. Meanwhile, can anyone point me in the right direction with the VBA code needed to color cells a certain color, depending on the corresponding cell content of another worksheet: Namely; 1) Worksheet 1 has a matrix with years running across the top and product names running down ...

Tender Type Scan Code
Hi everyone, What does the field Scan Code do when creating or editing a tender type? Does it allow me to select a tender type with a barcode scanner? Thanks in advance Rance Edwards Scan codes are used with programmable keyboards (ie PREH keyboards)...here's the help guide summary on scan codes pasted below: Scan code: The keyboard macro code used to directly advance to the tender type during a point-of-sale transaction (only if the keyboard has macro definition capabilities). For example, assume you have a programmable keyboard and want to program a code for the Cash tender type...

Add Trusted Code DLL Outlook Security Settings
I'm trying to add a trusted code DLL to my outlook security form, but if I click on the add button nothing happens. So I'm not able to browse and add any files as trusted code. We're using Exchange / Outlook 2003 and I've registered the trusted code files on my admin PC as it's described. Other configuration changes to the programmatic or outlook security settings tab are working just fine. Can anyone help??? ...

Delete a code
Hello How can I delete a code (same code to all sheets) which is inserted in 50 sheets in an excel file? Delete the code sheet by sheet or there is an alternative way more simple? Thanks in advance. I assume you mean VBA code. The more eligant way is not to have added it in the first place. I think you must of had some VBA in a sheet and copied it 50 times and now you don't want to distribute the code with you workbook. Next time only copy the sheet once. Delete the code, then copy it 50 times. ------------------------------- POSTED BEFORE RECEIVING A REPLY AFTER 6 ...

Code to select data
Hi - I am using v2007 and want to know code for selecting from row 2 to the end of populated data in a spreadsheet. The length of the data will vary everytime. Any help gratefully nreceived. Thanks. Anita Assuming you mean you want to select entire rows, give this a try... Dim LastRow As Long LastRow = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row If LastRow > 1 Then Range("2:" & LastRow).Select -- Rick (MVP - Excel) "Anita" <Anita@discussions.m...

window mail code 800cccdf for gmail
I can not send emails using this program i have checked my settings they are correct this is A New Computer with 1gb of Memory and almost 1tb of harddrive space here is one of the messages i get XOAUTH authentication failed. None of the authentication methods supported by your IMAP Server (if any) Are Supported on this computer Your IMAP command could not be sent to the server, due to non-network errors. This could. for Example indicate a lack of memory on your system. Configurate Account: my account name Server: imap.gmal.com User Name.: My User Name Protocol IMAP Port...

Capture value in worksheet & use in macro code
in macro have code: 01=Range("a3").value cell a3 is in worksheet & can contain word "Product:" or a number like 4 what code can I use to use what is captured in 01 above in a line of macro code such as: selection,autofilter filter = (value of 01) I am trying to run an autofilter from fields located in worksheet. thanks rleonard selection,autofilter filter = 01 "Robert E. Leonard Sr" <rleonard@mich.com> wrote in message news:e6fqv97uGHA.560@TK2MSFTNGP05.phx.gbl... > in macro have code: > 01=Range("a3").value > > > cel...

CheckBox Code to copy & paste range
Mobys of VBA, I 'm trying to write what I assumed was a simple copy & paste procedur using a checkbox value as the trigger. I have tried numerous variations but to no avail. I get no error messages, I also get no desired results except that everytime I run the code it does unprotect and protect th worksheet and it always clears the contents of rng2. The two named ranges (rng1 & rng2) are unprotected and the same siz and configuration (i.e. A20:A22, A43:A45 respectively) , but they ar on different sheets. Thanks for any help Here is my best code to date: Option Explicit Private Su...

GAL Extraction VB6 Sample Code using Redemption
Private Sub Form_Load() 'create a form, drag in a command button End Sub ' ------------------------------------------- ' The process is simple but sometimes getting there is painful. ' Redemption.dll is the only MAPI based data object required ' Download site is: http://www.dimastr.com/redemption/ ' After Installing: Project | References | [Browse] to installed folder ' Upon selection the reference is called "SafeOutlook Library" ' ------------------------------------------- Private Sub Command1_Click() Dim fld(15) As String ' http://su...

The RMS integration should allow for store dept code mapping
If it is possible to map the various accounts for the different stores, could it be possible to map the departments, even though they may be standard, to different item classes for each site (store). This is because some Great Plains set ups have item classes for the same items but differentiated by the different sites they are in. An example is say you have the item 'cell phone' that one sells. One then has 3 stores that they sell them in and in Great Plains they have set up 3 sites. To track item movement per store they have set up item classes for each site for example 'c...

Acessing new Vista/Win7 FIle Properties from .NET code?
I see in Vista and Windows 7, there is new Privilege Level property called "Run this program as an administrator" for EXE files. Is there a way to set this property in code? I have a copy of VS2010 Beta 2 running in a VM and checked the documentation for the FileInfo class but I didn't see anything. * Joe Cool wrote, On 19-1-2010 16:21: > I see in Vista and Windows 7, there is new Privilege Level property > called "Run this program as an administrator" for EXE files. Is there > a way to set this property in code? I have a copy of VS2010 Beta 2 > ru...

HTML code when Published
Please help. PUBLISHER 2000 I have created 7 pages of web copy including a page named index.html. I created a ftp signature for the two files. I have places all of this into a folder named html I have uploaded my info to my server Aplus. I have down loaded the files to the Aplus. When I type in address for my site I only see html code. What have I missed? JR from Iowa <JR from Iowa@discussions.microsoft.com> wrote: >When I type in address for my site I only see html code. > >What have I missed? You might get better help if you posted your question to: microsoft....

Need Help understanding code
This code works great but there are several things that I just don't understand. Can Anyone please help. First - I understand the Dim, what is the * 10000 for? Second - GetSetting("Demo", "Drafts", "Month", 0) There is no where in my workbook that refers to "Demo", Drafts", "Month", and what does the 0 do? Third - SaveSetting is that saving both the L and the M when I click the Yes buttom Private Sub Workbook_Open() Dim L As Long, M As Long L = Month(Date) * 10000 + Year(Date) M = GetSetting("Demo", "Drafts", &q...

Please Heeeeelp! Vba code to add animation to an existing object
I am a teacher trying to make a game using 2007, and i am trying to do two things. One is to add an animation like the spin to a picture by clicking on a botton, but all the examples i find , add the animations while creating a shape so i dont know how to make the animation to an existing picture in my slide. the other thing is to stop the animation by clicking on a button. I found an example to pause the slide but the problem is that i have other animations that are stopped as well and i cant use that. The picture is of a wheel with numbers that i want to spin so when i click th...

range loop? help
I have a series of queries that uses a range to autofilter. This works by working through a list in cells C8 to C34. At present I use the code detailed below but know there must be a way of excel working through this list more intelligently i.e. not having to name the cell to copy paste but work through the range in order. ----------------------------------------------------------------------------------------- Sub EditPt2() 'Filter each district 'District 1 Sheets("Control").Select Range("C8").Select Selection.Copy Range(&quo...

Need help to modify code to track changes in a column
I have been tasked with tracking if people fill in their time sheets in on time. I was able to find the following code to track and copy changes to rows within a spreadsheet, but I need to modify it to be able to do columns instead any help would be appreciated. -------------- Dim myRows() As Long Private Sub Worksheet_Change(ByVal Target As Range) Dim myRow As Long Dim myVal As Variant If Target.Cells.Count > 1 Then Exit Sub On Error GoTo NotDimmed test = UBound(myRows) GoTo Dimmed NotDimmed: ReDim myRows(1 To 1) Dimmed: For i = 1 To UBound(myRows) If myRows(...

VB code
I am using Office 2007. In Excel, I like to write a code in Visual Basic to copy the contents of the cell above into a blank cell down below and repeat the procedure until it reaches the bottom of the data. All the cells are not blank cells. Only a few of them are blank cells. Example of the column 03/01/2008 01/01/2008 02/01/2008 03/01/2008 03/01/2008 03/01/2008 11/01/2007 12/01/2007 01/01/2008 02/01/2008 I like to copy 01/01/2008 into the empty cell down below. Then move to the next blank cell and copy 02/01/2008 into the empty one. Repeat the procedure ...

Modify Code to format entire row of data
I had the following VBA that I use to format my reports: Option Explicit Sub boldFillRangeIfCBoldOrBNull() Dim i As Integer For i = 1 To 1000 If Cells(i, "c").Font.Bold = True Then Range(Cells(i, "a"), Cells(i, "O")).Font.Bold = True Range(Cells(i, "a"), Cells(i, "O")).Interior.ColorIndex = 15 End If If Cells(i, "B") = "" Then Range(Cells(i, "A"), Cells(i, "O")).Interior.ColorIndex = 19 End If Next i Reporting need have ch...

Where do I place the Code
Working in Outlook 97 I wish to close the Standard ToolBar but need to have the "Send" Button. I have used the control toolbox and selected a control button. Now, Where do I put the code and can you give me some idea of the syntax ...

coding a heads down data entry
I can't seem to get the right controls to do the following; keying in data one character "X" or Blank to auto advance to next element. The value of the "X" is 1 (One). The value of Blank being "0' (zero). There will be a lot of these one character fields. Not sure how to tell it "Text" when the value will 1 when an "X" is entered. Of course the enter key will advance leaving blank. I hope this isn't a stupid question. :) Izod If I understand you correctly you want the cursor to move from field to field without pres...

UPC Universal Product Code
I find it interesting that there is no predefined location for UPC codes in Inventory Control. Of course, you could use either the general or short description. But this would only work if there were a one to one relationship (One UPC to ONE Inventory Control SKU). In my case, we have multiple UPC’s for the same SKU. To get around this we could use the manufacturer part number form and table. But unfortunately we want to map both UPC’s and manufacturer part numbers. I would think that your customers would be screaming for this functionality. All that it would take is for develop...

Coding Issue
Morning and Happy New Year all. I am having an issue with a code I'm trying to use to change the back color of some text boxes I'm using on my form. The actual issue is not that the code is not working. It’s just only working with one text box. I would like to know how I would fix this code to change a group of numbers and not a series of numbers. i.e. "220, 222, 224, 226" - AND NOT - "220 To 226" Now, when I try and enter it in example A it does not allow the comma. Example B gives me an error because there are no odd numbers. I have tried changing th...

automatically generate item look up code
is there anyway RMS can automatically generate items look up code according to items department. for example if we add an item in a department called "cigar" the item lookupcode should have a prefix of category "cigar" which can be "01" and then a serialized lookupcode. for example if the last item entered in the cigar category has code "01150" the next item we add in this department should automatically get the lookupcode as "01151". can anybody please give me any idea on how can i go about doing this. any advice or comment will be mu...

VBA code #3
how to set the value of a variable? example: Dim FiletoPrint As String And then I want to assign a value to FiletoPrint What's the syntax in VBA? FiletoPrint:= "S:\66103\04TILL\file1" ? thanks, Mary Just and equal sign, no colon. The syntax := is used only with named arguments in procedure calls. On Mon, 25 Oct 2004 11:51:22 -0700, "Mary" <anonymous@discussions.microsoft.com> wrote: >how to set the value of a variable? > >example: > >Dim FiletoPrint As String > >And then I want to assign a value to FiletoPrint > >What'...