Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Figuring out which object type opened 1

Status
Not open for further replies.

zevw

MIS
Jul 3, 2001
697
US
Is there a way to figure out if the object on the screen is a form or a report.

Can I write a function when a form opens I can capture if its a form and if its a report capture the report and manipulate the menu bar.

Thanks in advance!
 
dim frm as access.form
dim rpt as access.report
select case Application.CurrentObjectType
case acForm
set frm = screen.activeform
case acReport
set rpt = screen.activereport
end select
 
I Thank You for the valuable information.

I have a minor problem I created a function and call it in the open event procedure

Code:
Private Sub Form_Open(Cancel As Integer)
    
    CurrentDb.Properties("AppTitle").Value = Nz(DLookup("HName", "Company"), "")
    Me.Company.Caption = Nz(DLookup("HName", "Company"), "")
    
    GetActv
   
    Application.RefreshTitleBar 'Update On Screen!

End Sub
and it is giving me this error

Run-time error '2475':

You entered an expression that requires a form to be the active window.
[/color red]
only when I startup the Main Form

Once the Main formis loaded it works Dandy!

here is my code
Code:
Public Function GetActv()

  Select Case Application.CurrentObjectType
      Case acForm
          CommandBars("Base").Controls("Print").Visible = False
      Case acReport
          CommandBars("Base").Controls("Print").Visible = True
  End Select

End Function

Any ideas why once its loaded its unhappy?



 
Try to use the Load event procedure instead of the Open.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I put it all the way at the end the Load Event Procedure and it works fine.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top