Determing active form to process function

I suppressed the Ctl-P shortcut by creating a ^p autokey macro that does 
nothing.  Now I want Ctl-P to execute a function if a specific form is open 
and do nothing otherwise.  I added a condition to the macro that if the 
active from is Data Entry ([Screen].[ActiveForm].[Name]="Data Entry"), it 
should run the function and the next command is StopMacro.  The function runs 
correctly if the active form is Data Entry, but it returns the error "The 
Object you referenced in the Visual Basic Procedure as an OLE object isn't an 
OLE Object" if the screen the user is on is a report.  What is needed to get 
it to evaluate the way I want it to?
0
Utf
1/26/2008 7:11:02 PM
access.formscoding 7493 articles. 0 followers. Follow

4 Replies
1192 Views

Similar Articles

[PageSpeed] 31

Screen.ActiveForm.Name is the best way to determine the name of the active 
form.

As you say, that generates an error if no form is active (e.g. a report is 
active.) Just add error-handling to deal with that error.

If error handling is new, here's an introduction:
    http://allenbrowne.com/ser-23a.html

-- 
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.

"scott" <scott@discussions.microsoft.com> wrote in message
news:5477E5F4-ED17-4C80-A381-2B57414393DB@microsoft.com...
>I suppressed the Ctl-P shortcut by creating a ^p autokey macro that does
> nothing.  Now I want Ctl-P to execute a function if a specific form is 
> open
> and do nothing otherwise.  I added a condition to the macro that if the
> active from is Data Entry ([Screen].[ActiveForm].[Name]="Data Entry"), it
> should run the function and the next command is StopMacro.  The function 
> runs
> correctly if the active form is Data Entry, but it returns the error "The
> Object you referenced in the Visual Basic Procedure as an OLE object isn't 
> an
> OLE Object" if the screen the user is on is a report.  What is needed to 
> get
> it to evaluate the way I want it to? 

0
Allen
1/27/2008 1:08:45 AM

"Allen Browne" wrote:

> Screen.ActiveForm.Name is the best way to determine the name of the active 
> form.
> 
> As you say, that generates an error if no form is active (e.g. a report is 
> active.) Just add error-handling to deal with that error.
> 
> If error handling is new, here's an introduction:
>     http://allenbrowne.com/ser-23a.html
> 
> -- 
> 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.
> 
> "scott" <scott@discussions.microsoft.com> wrote in message
> news:5477E5F4-ED17-4C80-A381-2B57414393DB@microsoft.com...
> >I suppressed the Ctl-P shortcut by creating a ^p autokey macro that does
> > nothing.  Now I want Ctl-P to execute a function if a specific form is 
> > open
> > and do nothing otherwise.  I added a condition to the macro that if the
> > active from is Data Entry ([Screen].[ActiveForm].[Name]="Data Entry"), it
> > should run the function and the next command is StopMacro.  The function 
> > runs
> > correctly if the active form is Data Entry, but it returns the error "The
> > Object you referenced in the Visual Basic Procedure as an OLE object isn't 
> > an
> > OLE Object" if the screen the user is on is a report.  What is needed to 
> > get
> > it to evaluate the way I want it to? 
> 
> 
0
Utf
1/27/2008 7:01:01 PM
I'm not sure what happened in my last reply (there was an entry, but no text 
that I could see), so I am putting it in again.  My apologies if it is posted 
twice.

This gets me closer, but I'm still having trouble getting it to behave.  I 
now have a one line autokey macro with no condition that just calls a 
function.  The function then looks to see if the Data Entry form is open and 
runs code if it is.  The end of the code puts up the Print Dialog box so the 
user can print the report.  If the report is open, the resulting error (2475) 
is trapped and it then just puts up the print dialog box (DoCmd.RunCommand 
acCmdPrint).  This works fine as long as the user doesn't canel printing.  It 
even works fine if the user cancels printing and they invoked the command 
from the Data Entry form.  The function traps the error (2501) that results 
from canceling the printing and just goes back to where it was.

If the user is in the report when ^p is invoked, it works fine if the user 
does not cancel.  If they cancel, the Micosoft Visual Basic error message 
(2501) comes up that the RunCommand action was canceled and gives the buttons 
End, Debug and Help, not a screen I want users to see.  When I click Debug, 
it goes to Line1 (see Code) and when I reset, it displays the Macro Action 
Failed screen.  I've tried a few variations on the error trapping, but I get 
the same (or worse) results.  Can you help me get this to behave correctly?

Public Function DisplayRequest()
On Error GoTo Err_DisplayRequest

    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim Problem As Integer
    Dim intRecCount As Integer
    Dim intAmount As Currency
    Dim intEmpty As Integer
    Dim intChkreqid As Integer
        
If [Screen].[ActiveForm].[Name] = "Data Entry" Then
    Runs some code
Else
Line1:    DoCmd.RunCommand acCmdPrint
    DoCmd.Close acReport, "Check Request"
End If

Exit_DisplayRequest:
    Exit Function

Err_DisplayRequest:
    Select Case Err.Number
    Case 2501
        Resume Next
    Case 2475
        GoTo Line1
    Case Else
        MsgBox Err.Description
        Resume Exit_DisplayRequest
    End Select
    
End Function

"Allen Browne" wrote:

> Screen.ActiveForm.Name is the best way to determine the name of the active 
> form.
> 
> As you say, that generates an error if no form is active (e.g. a report is 
> active.) Just add error-handling to deal with that error.
> 
> If error handling is new, here's an introduction:
>     http://allenbrowne.com/ser-23a.html
> 
> -- 
> 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.
> 
> "scott" <scott@discussions.microsoft.com> wrote in message
> news:5477E5F4-ED17-4C80-A381-2B57414393DB@microsoft.com...
> >I suppressed the Ctl-P shortcut by creating a ^p autokey macro that does
> > nothing.  Now I want Ctl-P to execute a function if a specific form is 
> > open
> > and do nothing otherwise.  I added a condition to the macro that if the
> > active from is Data Entry ([Screen].[ActiveForm].[Name]="Data Entry"), it
> > should run the function and the next command is StopMacro.  The function 
> > runs
> > correctly if the active form is Data Entry, but it returns the error "The
> > Object you referenced in the Visual Basic Procedure as an OLE object isn't 
> > an
> > OLE Object" if the screen the user is on is a report.  What is needed to 
> > get
> > it to evaluate the way I want it to? 
> 
> 
0
Utf
1/27/2008 7:26:02 PM
Thanks for your help.  I solved the problem by creating another function that 
is called when the 2475 error is trapped.  Now it behaves the way I want it 
to.

"Allen Browne" wrote:

> Screen.ActiveForm.Name is the best way to determine the name of the active 
> form.
> 
> As you say, that generates an error if no form is active (e.g. a report is 
> active.) Just add error-handling to deal with that error.
> 
> If error handling is new, here's an introduction:
>     http://allenbrowne.com/ser-23a.html
> 
> -- 
> 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.
> 
> "scott" <scott@discussions.microsoft.com> wrote in message
> news:5477E5F4-ED17-4C80-A381-2B57414393DB@microsoft.com...
> >I suppressed the Ctl-P shortcut by creating a ^p autokey macro that does
> > nothing.  Now I want Ctl-P to execute a function if a specific form is 
> > open
> > and do nothing otherwise.  I added a condition to the macro that if the
> > active from is Data Entry ([Screen].[ActiveForm].[Name]="Data Entry"), it
> > should run the function and the next command is StopMacro.  The function 
> > runs
> > correctly if the active form is Data Entry, but it returns the error "The
> > Object you referenced in the Visual Basic Procedure as an OLE object isn't 
> > an
> > OLE Object" if the screen the user is on is a report.  What is needed to 
> > get
> > it to evaluate the way I want it to? 
> 
> 
0
Utf
1/27/2008 9:25:00 PM
Reply:

Similar Artilces:

Read Only error when completing activities in SFO
When I close an activity in SFO and mark it as complete I receive a warning dialog that states that the record in CRM is read only and it will not be updated. How can I get the record to update properly in CRM when I mark it as complete in SFO? ...

Lookup Function in user form
I have a combo box (cboitem1) and a text box (txtprice1). I am using the code below to have txtprice1 fill with the corresponding price the worksheet: Private Sub Cboitem1_Change() If cboItem1 <> "" Then txtprice1.Value = Excel.WorksheetFunction.VLookup(cboItem1.Value, Sheets("Pizzas").Range("A1:B65536"), 2, False) End If End Sub It works perfectly when you enter an existing value in cboitem1. However if 'the user' accidently types a letter that is not the first letter of one of the existing items VB debugging pops up with error &qu...

Track in CRM function
Hello. Upon selecting the “Track In CRM” button from the CRM line in Outlook I have two questions based on situation: 1) If the contact exists in CRM it appears to attach the email but provides no notice unless you try to attach it again? True? 2) If the contact does not exist it attaches the email where? In v1.2 it opened a window and made the user create a record. I think it is attaching or tracking the email in CRM somewhere because trying to do it again, I'm asked if you want to attach/track it again. Does this make sense? By the way, we are using CRM 3.0 Thanks. After c...

Great Plains order processing
I am using Microsoft Dynamics GP 9.0 version 9.00.0310. At our company we have a need to add an additional Sales Order Type ID to our orders. We want to have a different order type associated with Warranty Returns, versus standard Sales orders. Reason behind this is because of the end result of a Crystal report we need to generate during Order fulfillment. Our ultimate goal is to have a commercial invoice generated at time of fulfillment. But the commercial invoice needs to have different results based on the type of order. For instance, a sales order would have a cost associated with th...

Which Controls to Build a Parent/Child Web Form
Hi there, I'm quite new to asp.net, but know exactly how to do this using classic ASP, but would like some pointers for aspnet2. I've got data being returned from an SP which looks like this: HeaderItem ChildItem A A1 A A2 A A3 B B1 etc I want to display the data like this A - This is the header record A1 A2 A3 B - Header 2 B1 etc. In classic ASP I'd write out my header row html when HeaderItem changes value and then write the Child Rows. As I've on...

Tracked changes function misbehaving
I have a simple workbook (2002) in which the Track Changes feature is enabled. End users have reported periodic problems with the contents of cells "mysteriously" changing. In process of investigating these, have found that when tracked changes are highlighted, the comments that describe changes are not always associated with the correct cell. Example, comment on cell B114 states "Changed cell B114 from '<blank>' to '12345'". In fact, contents of cell B114 is "67890" and contents of cell B104 is actually "12345". Has anyone...

Activity Attributes
I am trying to write a report through crystal reports linking activities with particular orders. Is there a way to open up activity forms for modification so that I can see the schema names of certain fields. Most are self-explanatory but there are a few that are not. Please advise. no you cannot do this. Exactly what fields are causing you problems? -- John O'Donnell Microsoft CRM MVP http://www.mscrmfaq.us <dkoleno@cancerconsultantsinc.com> wrote in message news:09b601c50eee$6e9570e0$a401280a@phx.gbl... > I am trying to write a report through crystal reports > li...

addressing envelope from data input form
I don't know where to start to try this. I have the following fields that make up the entire address: Fname Lname Fname2 Lname 2 Address City, State Zip Is there any way to "push a button" on a form and have it print an envelope for that record? Thanks in advance for any help. -- Posted via a free Usenet account from http://www.teranews.com Have you thought of using an MS template as a starting point? http://office.microsoft.com/en-us/templates/CT101172481033.aspx Dave Eliot wrote: >I don't know where to start to try this. > >I have the following fields ...

Viewing xml created in .Net in a ASP form VB6
I have been trying to create an xml document in VB.Net for displaying on an existing page written in ASP. im having a type mismatch error in my code. When i view my XML i have the following included in the <binary> node. <Binary xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64">DATA HERE </Binary My issue is how do i set the datatype of the the node using dotnet so that i can replicate the same node structure and use my existing ASP page. thanks in advance Colin Graham ...

List of kernel mode compatible functions
Hi, Is there a list of kernel mode compatible C/C++ functions (preferably for WDK 7600)? Thanks, Jan Wouldn't that be the WDK Help file? Thomas F. Divine "Jan M" <jan_m@jerseymail.co.uk> wrote in message news:e7fhXcanKHA.1548@TK2MSFTNGP02.phx.gbl... > Hi, > > Is there a list of kernel mode compatible C/C++ functions (preferably for > WDK 7600)? > > Thanks, > > Jan > Your right of course. I just didnt look hard enough. Jan ...

Creating a form or template
We scanned in an image of a post it note that has graphics on it. It is a jpg file. Can we somehow make this jpg file a form or template in Outlook? Ideally, we want to pull up a form that looks like the image of a post it note with the graphics in tact and be able to compose a message on the email post it note. How do you accomplish this? Thanks! ...

Adding BMPs to a form
I use Access 2003. I have a table set up with a field for pictures, this table sits behind a form to add BMPs, which display on the form and print on reports. In the past, when I have had to reinstall Access for any reason, the pictures instead of displaying fully in the form, only show as thumbnails with the file name. I have in the past resoved this by removing Microsoft Picture manager from MS Office. I don't know how I figured that out or why it works but it does. However, I had to reinstall Office yesterday, removed MS Pictrue Manager as usual and it's NOT working ...

Set Out of Office (or a rule) to only function on weekends
Hello, I am trying to set up so that every weekend my internal e-mail gets forwarded to my home(smartphone) account. I can only find options to run a rule or out of office assistant to run for specific date ranges. How do I set up either a rule or the out of office assistant to 'push' mail to me only on weekends? HCA.CWT.RN wrote on Fri, 02 April 2010 09:04 > Hello, I am trying to set up so that every weekend my internal e-mail gets > forwarded to my home(smartphone) account. I can only find options to run a > rule or out of office assistant to run for spec...

Removing gray shading in protected forms (drop down box)
Hello- I am creating some contract templates for my company's sales force using Word 2003. I am using the forms toolbar to insert checkboxes and drop down boxes from which to select deliverable specifications. The problem is that when a user selects an option from the drop down box, the gray shading remains. I know the sales teams HATE the gray shading because they don't think it looks very good when sending to customers. Is there a way to disable the shading when an option is selected? Thanks. You can remove form field shading altogether using the corresponding b...

Using a OR() like function in an IIF statement
Hello, I am trying to create an IIF statement to test if the first character in a field is a 1,2,8 or 9. Something like the following: IIf(Left([possible_SO_match],1)="1 or 2 or 8 or 9",[Possible_SO_Match],"No Match") Is there a way to create it without going to a 4 level nested IIF statement? Thanks, Kerry -- Message posted via http://www.accessmonster.com kkulakow via AccessMonster.com wrote: > Hello, I am trying to create an IIF statement to test if the first > character in a field is a 1,2,8 or 9. > Something like the following: > > IIf(Left([possib...

FORECASTING SALES (please let this be a worksheet function)
Hi I have recently been given the task by my boss to forecast one of ou key customers monthly usage until monthly until end of 2006, I am starting with this customers indidual branches monthly usage fo the past 3 years, Some branches will have opened and closed during thi time, And i am looking to be able to predict monthly usage for the nex 18 months Has anyone got any idea's on the best way to forcast within excel, I a currently using trend (fomulae given to me on this sight) but people ar saying this is not the best way Exponentionally has been mentioned by a few of my collegues but...

Combo values from query based on form fields
I am setting the values for a combo box in a form(s) via a query that 'filters' the results with criteria based upon the values of other fields on the form. The combo is a field that is bound. However, this is giving all kinds of problems ranging from Access completely crashing to being asked for the parameter values of those criteria fields when closing the form. I have tried making the combo an unbound field and then setting the value of the bound field to that unbound field after update, but that still leads to the same issues. How can I do this? As example - I have a form w...

Assigning Accounts should not assign cases and activities
Our Tech Support team manages cases. They lose track of the cases when we assign Accounts because they don't own the account. We also have many people with activities for accounts they don't own. They lose track of the activities. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree&quo...

ActiveX vs Forms
Hello- I am trying to embed some option buttons on a worksheet. I want to have two sets of buttons which are mutually exclusive, say A-D and then 1-3. I want to start with 1-3 hidden and if the user chooses option D from the first set then 1-3 will be revealed. I did this fine with the activex option buttons and VBA, however, it is not recognizing A-D and 1-3 as separate groups. Therefore, as soon as the user select 1,2 or 3, it will uncheck D and therefore rehide the remaining numbered boxes. I grouped and named each set of buttons together, but that did not work. If I try to use a group...

Refresh Results In A Second Subform In A Form
Hi, This could be a tricky one. What I've done is created a Form named ACCOUNTS SELECT which has a control being a Comb Box named 'PICK RESNAME' and an embedded subform which returns all the records according to the particular data from the 'PICK RESNAME' Combo Box. Thats all fine and well ! But what I need is to pick specific records and to store them in a let's say temporary Table which I will print out via a Report. For this temporary table, I have created in the Form ACCOUNTS SELECT another Subform which I hoped will view all the selections I have made...

Continuous Form, Window Top Record Ordinal
On continuous view forms, there should be a form property that has the recordset ordinal of the top-most record currently displayed in the form’s window. For example, if a recordset contains 100 records and the CurrentRecord is 5 and the user scrolls down until the CurrentRecord disappears off the top of the screen, what is the recordset ordinal for the record that is now at the top of the window? Left clicking on the scrollbar slider will display “Record: x of y”, but there should be a property that contains the value of x for code purposes. Perhaps call it “WindowTopRecord...

sorting activities for each lead/contact by actual end dates
When I view the activities associated with each lead and contacts, the actual end date are not shown. Does anyone know how I can dispaly this field? The activities list in workplace does show the actual end dates but we'd like to see that when we access the list through indivial contact/lead record. Thanks, Victoria Hi Victoria, There is no good out of the box way to do this in MSCRM today. We're working hard to fix this for v2.0. Many of our customers have worked around this issue by registering for a post call out on the activity creation, and then having a custom object wh...

Need to insert a picture using a function
I would like to know if it is possible to insert a picture (.jpg) using a function. I have a simple quote sheet setup for my customers and would like to insert a picture of the product next to the quote information. Is it possible to insert a picture based on what i enter as my product number?? I know this is a vague question, sorry. Someone help please!!! Try this link for a possible solution:- http://www.mcgimpsey.com/excel/lookuppics.html -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 00/02/03 -------------...

Extra pages in form printing
I have a form that exceeds a single printed page. When it is printed extra pages are produced. The extra pages occur after the first printed page but before the rest of the page of the form is printed and another extra page after the rest of the page is printed. The extra pages contain the same background used in the form. In design view I've made sure to shorten up the background to be even with the footer but it doesn't seem to help. Any suggestion on how to get rid of the extra pages in my printout? Thanks. -- Linda I still do not understand why people print forms. For...

Printing Form 1096
This function should be included in the software! ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=20ff4f89-dda7-4896-96f2-6d18c0df63b1&dg=microsoft.public.greatplains T...