Debugging environment code

B

Bryan Dickerson

Is there some code that I can put in my Custom Form VBScript to tell that
I'm in the development environment? So that I don't execute code that is
meant only for the production environment? Something like "If Debug <> True
Then"???

TIA!
 
B

Bryan Dickerson

I read your response and didn't quite understand it, but I went ahead and
tried what I thought you meant by checking for the "Forms" menu item.

MsgBox "Item.GetInspector.CommandBars.ActiveMenuBar.FindControl(,
30145).Visible is " & _

Item.GetInspector.CommandBars.ActiveMenuBar.FindControl(, 30145).Visible

I put this in the Item_Open Event and it returns false either way. What am
I doing wrong?
 
S

Sue Mosher [MVP-Outlook]

You're using not the parent CommandBars, but a child menu. Try it this way:

Set objInsp = Item.GetInspector
Set colCB = objInsp.CommandBars
Set objCBB = colCB.FindControl(, 30145)
If Not objCBB Is Nothing Then
MsgBox "CommandBar ID 30145 Is visible (T/F): " & objCBB.Visible
End If
Set objCBB = nothing
Set colCB = Nothing
Set objInsp = Nothing

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Bryan Dickerson

It still says "False" both ways. I guess I'm still doing something wrong.
Hmmm... Could it be that I have it in the Item_Open event which actually
runs before anything is displayed? If so, then is there anything else? My
dilemma is that I have a database insert in the Item_Open that I would
really not like to happen if I'm working on the form, but if I'm opening up
the form for testing or if a user is opening the form then it's ok. I get
tired of going back and deleting all the records that got inserted just
because I was editing the form.
 
S

Sue Mosher [MVP-Outlook]

Ah, you're using this code in the Item_Open event! I think you're correct
that Item_Open fires *before* the item switches into design mode and that,
therefore, there's no way to use that event to determine what state the item
is in.

Why are you doing a database insert in Item_Open? Wouldn't that create a lot
of extraneous items when the user opens and item and then discards it?
 
B

Bryan Dickerson

True. I guess I was so enamored with the way the ODBC stuff was being
inserted and running so well that I lost track of the program flow. It
would make more sense to wait until the user hits the "Save" button to do
the insert.

Thanks for the perspective, too!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top