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
900 Views

Similar Articles

[PageSpeed] 36

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:

Activate Analytical Accounting
Received the following error message when activat Analytical Accounting. Error message, Ciolation of PRIMARY KEY constraint 'PKAAG20001. Cannot insert duplicate key in object AAG20001 ...

how to activate quick acess toolbar,i can't click on it?
quick acess tool bar is there but it is not active so i can't click on it. i went to right click on print preview button.but there also quick acess tool bar button is not active,i cant click on it, it show lighter colour. ...

Active Sync
We are about to go to Exch 03 at the end of this month. I want to know - does the active sync component work with iPaqs or just Windows phones? -- J. Bogut A+, MCP, MCSE All Windows Mobile versions with ActiveSync will work, and even more... -- Regards, Menko den Ouden MCSE+I Netherlands "jb" <jb@nooakknoll.org> wrote in message news:%23YllTf$$FHA.1288@TK2MSFTNGP09.phx.gbl... > We are about to go to Exch 03 at the end of this month. I want to know - > does the active sync component work with iPaqs or just Windows phones? > > -- > J. Bogut > A+,...

Sub queries in Active Reports
I am trying to create a report that lists all the checks processed each day which includes both purchases and payments. I need to use a subquery to make it happen. The report complains with an error "TenderEntry.TransactionNumber" could not be bound..... I can run the query just fine inside SQL Management Studio. Does anyone have an example of this type of query that works with Active Reports? thanks, Keith After further experimenting, I found the solution to the problem. I had to us an alias (AS te) for the TenderEntry table. Then it worked in the Active Report....

Exchange active sync and host headers?? error 0x85010004
Getting support code: 0x85010004 on Device. Background, We have implemented single exchange server, has Thawte SSL Server Certificate installed. Did all the single server work arounds that are required to get SSL working on a single server. AS outlined in many MS QB's. WE have rechecked all of this. From outside we can connect to OWA using https://outlook.mydomain.com. I think we made one mistake with Exchnge active synce and OMA and that is to make it easier for our web users we put in the recommended host header at the defualt website that redirects users to the /exchange ...

Re : Migrating emails from active Exchange 2000 to a offline Exchange 2000
I need to move emails from a production Exchange 2000 to an offline exchange 2000 and move it back later to the same exchange server 2000 after repair or reformat .... something like moving the .pst from 1 desktop computer to another desktop for viewing that I have the correct files loaded. Paul This group is for questions around Microsoft CRM but here's the answer for you. You need to use a utility called EXMERGE. This allows you to take everyones exchange data and store it in a file called user.pst etc YOu can then rebuild your exchange server and use exmerge again to reimport t...

Excel Hyperlink Management, Functions, and MS Word
Is there a text function that returns a specified range within a cell reference? for instance given the below conditions, i'd like a1 to return "yahoo" (characeters 12 through 16 of cell b1) and have the hyperlink show up in c1 a1 = ? b1 = http://www.yahoo.com c1 = hyperlink(b1,a1) d1 = find("http://www.",b1)+11 returns 12 e1 = find(".com")-1 returns 16 Basically what i'm trying to do is organize my favorite links in excel (Column C), and then move them to MS Word without having long urls displayed on my word document. My procedure for d...

My active contacts
How can I customize the contact view form to be able to select a list of contacts from the active contact list and make them available in my active contact list. It should not allow to select the contacts that are already available in my active contact. I was thinking of having an item called "my active" in Actions menu which will let me do this. Is it possible to do this customization ? If yes, can someone tell me steps to do this. Any other suggestions to resolve my issue ? This can be done by Assign...please ignore this question discussion11@yahoo.com (Arch) wrote in message new...

Form Changes 11-21-09
I have a rather large database that has been through several conversions of Access. The latest problem )with Access 2007) is that changes to forms will NOT save. I am transfering it to my computer through VPN. -- bclmfte ...

Auto fill field on form
Using 2007 -- Have a form with customer ID and customer name. Would like to enter the customer ID and have it automatically fill in the customer name. "Deanna" <Deanna@discussions.microsoft.com> wrote in message news:61C42352-D05E-4AF6-BE43-F255D7A15E1C@microsoft.com... > Using 2007 -- Have a form with customer ID and customer name. Would like > to > enter the customer ID and have it automatically fill in the customer name. That's easy, but remember, you should not store the customer name twice, NOT FOR ANY REASON. Use a combo box with 2 columns...

Forms #3
Have added form to website (http://sandrahand.com/gourmetclub/becomeamember). Host is godaddy.com; have installed frontpage extensions (deleted and reinstalled today); have email off of domain at GoDaddy; continue to receive message about form not being able to config to send results via e-mail. Bizarre. Also, confirmation page (http://sandrahand.com/gourmetclub/confirmation) does not appear after submit on page where form is located. Receive error page. Have spent HOURS! Help! Thanks! ...

[ANN] Apple Security Update blocks Microsoft's update process
Microsoft updaters include a step to safeguard users that have not followed directions to quit all applications before updating. However this safeguard is now blocked by a recent Apple security update. This affects Leopard users only! Read the full story here.... Apple Security Update blocks Microsoft's update process (The Entourage Help Blog) <http://blog.entourage.mvps.org/2008/08/apple_security_update_blocks_microso fts_update_process.html> In case the above link does not work: <http://ub0.cc/79/3> -- Diane Ross, Microsoft Mac MVP Entourage Help Page <http://www....

Determing Column Name
I am trying to determine the column name based on an expression. My table has column names like GROSWAGS_1, GROSWAGS_2, etc. The number represents a month. Here's what I've got so far. declare @GrossWagesColumn as Char(30) declare @MonthNumber as Int Set @MonthNumber = 4 Set @GrossWagesColumn = '['+'GROSWAGS_'+LTrim(RTrim(Cast(@MonthNumber as CHAR(2))))+']' Select employid, @GrossWagesColumn as GrossWages from Table1 Unfortunately, I'm getting the table name in my results instead of the data for the column. EMPLOYID GrossW...

Search form in Contacts Management Database
Hi, I have downloaded the Contacts Management template for Access 2003 and while it has most things I need I have found it frustrating that there is no easy way to search through contacts, and I am sadly not a very good Access developer! I would like to develop a search form where the user can type in a few criteria (e.g. first name is like 'Mar' and last name is like 'Smit') and it will return the pages for all records that have similar first and last names (e.g. Marc Smith, Mark Smith, Marc Smit etc). I can easily does this through a query, however as the end users a...

custom control to display images in Continuous Forms
OK forget my earlier post about inserting PNGs into OLE fields. (even just using OLE "Links" there's just too much filesize inflation.) The usual trick of storing filenames for images and displaying them in an unbound image control is now what I need to do. But I need to do it in *Continuous* Forms. Obviously no standard Access control will do this. But I figure there's got to be a custom control that can be bound to a text field of a filename, and display the image. Hopefully a cheap or free custom control? anybody got any ideas? hah tia roger roger try arvins ...

TREEVIEW Win Forms
I want to access on child node on click method? treview1.node.nodes(?) ... ???? Thanks ... This group is for VB6 and earlier(VB Classic). VB.Net and all dotnet groups have either "dotnet" or "vsnet" in the group name. Please use the following group instead: news://msnews.microsoft.com/microsoft.public.dotnet.languages.vb "Winforms" are .Net. This group is for VB. If you're using VB.Net you're in the wrong group. Try here: microsoft.public.dotnet.languages.vb > I want to access on child node on click method? > >...

Activities-Viewing content of activity as in 'Reading Pane-Bottom
Can we not have a similar view for activities as you do in the email section in Outlook - i.e. the 'Reading Pane' - when it is set to 'Bottom' so that you when click(highlight) on the activity and you can view the contents in a split screen style - that way you don't have to double click and open yet another window? This would be a much faster way of viewing and you only need to open it if you want to edit it. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click th...

Activate/Deactivate Toolbar button(s)
I want to activate/deactivate a Toolbar (whole or few of the buttons) depending on whether any child window is open or not in an MDI app. Where exactly should this be implemented? First check could be in the ON_UPDATE_COMMAND for the indivudual Toolbar buttons checking for any open Child Frames. Where should I check if any further Child Frames are opened or not once a Frame has been closed? In the PostNcDestroy? thanks in advance! By "Child Window" I presume you mean any view on a document (and then the question is whether the buttons apply to the view or the document). In eith...

Applying Workflow to Activities
Is there any way to apply a workflow rule to more than one Activity at a time? Ideally, I would love to do an Adv Find for my Activities and then highlight them all and apply the rule from there. Any suggestions? James ...

SOP Blank Invoice Form Comments field
I want to know how I can enter the data for the Comments field in the Blank Invoice Form. I was able to print a comment on the Comment (1) field using by entering a Comment ID on the Comment field. Where do I put if I want to print on the Comment (2), Comment (3) and Comment (4) fields. Thanks when entering a comment you are entering into a large text field. By default you can print 4 lines of 50 characters on the Blank Invoice Form. The large text field is automatically split into the 4 Comment fields. So basically Comment 2 is used if you exceed 50 characters or put a hard return i...

How do I use a function or a macro, so as to list the names of AL.
Trying to create an index in the first worksheet (automatically) and I need either a function or a macro, so as to list the names of ALL the worksheets in the current Workbook. Thanks for any help. Hi see: http://www.mvps.org/dmcritchie/excel/buildtoc.htm "TitinMTIUS" wrote: > Trying to create an index in the first worksheet (automatically) and I need > either a function or a macro, so as to list the names of ALL the worksheets > in the current Workbook. Thanks for any help. Hi, Thanks a million "Frank Kabel" wrote: > Hi > see: > http://www.mvp...

ol 2000 customised contact forms used on with ME server
please, please would some plain-speaking non-technical person help me with my probs? i have absolutely no development knowledge and am scared to play too much, however I have designed my own very specialised Contact Form which is published in the organisational library and is the default form for a Contact sub-folder called 1:1. 1. I would dearlylike to know a way for files/items to be inserted in to any field other than Notes. 2. When inserting the text only of an email into Notes, can I change the date to exclude the time?... and to be always inserted in a specific font, size and colour (...

Form Data to other excel file
Hi, I have a form which currently adds inputted form data to next blank row into a worksheet. It works fine but it seems that users have been able to change or delete this sheet when they shouldn't. Can I have this data added to a master workbook as well as its current sheet so information can be checked or retrieved if this does happen. It would be nice to have a central register anyway. Many thanks in anticipation Don H ...

Problems linking the fields in two forms
I created a command button on my form so that I can open up another form to save space and make it look neater on my main form. The common field between these two forms is the PO (Purchase Order) number but the subform that opens up does not autopopulate that same number from the primary form - how can I fix this? -- Kenji Could you explain how you open the secondary form (not subform)? Macro? What action(s)? Code? What lines? -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at m...

Add Members to Marketing List and Resend Campaign Activity
We are studying how campaigns and marketing lists work and see that once you have sent a campaign activity, you can't send it again. If you are managing an event, it's likely that you will continue to add members to your marketing list after the email invitation has gone out. Is there a way to send the campaign activity to the newly added members, and exclude those that have already received it? ...