Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2005

Tip: Looking for answers? Try searching our database.

OnBeforeChange event handler

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
smaur - 02 Aug 2005 18:15 GMT
Hi,
I have a repeating table for which I have created an OnBeforeChang
event.

The idea is that the table contains a field which is automaticall
populated with the UserName (using a rule), so that each table entr
(row) can be properly attributed to the user that inserted it. Thi
part works fine.

What I want to do is to permit deletion of an entry only if the curren
user is the one who made the entry, so this line is in my "if... else
statement:
if (strUserName =
DataDOMEvent.Source.selectSingleNode("@CommentBy").text)
//code to allow deletion
else
//code to prevent deletion

etc.
THe problem is that the comparison is being made between th
strUserName, and EVERY entry in the table, not just the one with th
focus at the time the delete command is made. As such, it alway
evaluates true and permits the event.
Is there a way to make this work such that the comparison is made onl
with the row that has the focus?

Thanks

--
smau
Adam Harding - 03 Aug 2005 11:58 GMT
smaur

Are you familiar with the current() function?

This does exactly what you want it 'focuses' the query on the current row of
the table.

post a reply if you want some examples.  I use it for cascading results
through multiple field selections but it is code so wil ldo the job anyway

> Hi,
> I have a repeating table for which I have created an OnBeforeChange
[quoted text clipped - 23 lines]
>
> Thanks!
smaur - 03 Aug 2005 13:09 GMT
Adam,
Thanks for your reply. I would appreciate seeing some examples. I hav
found a few, but since I'm just learning Jscript now I could use th
help.

smau

--
smau
smaur - 04 Aug 2005 14:44 GMT
I solved this problem by testing for strUserName != @CommentBy, and i
now works. Here is the complete function:

function msoxd_d_lkpComments::OnBeforeChange(eventObj)
{
    var oNetwork = new ActiveXObject("WScript.Network");
    var strUserName = oNetwork.UserName;
   
        if (eventObj.Operation == "Delete" && eventObj.Site =
eventObj.Source && eventObj.NewValue == null && strUserName !
eventObj.Source.selectSingleNode("@CommentBy").text)
            {
            eventObj.ReturnStatus = false;
            eventObj.ReturnMessage = "You cannot remove a comment entered b
someone else";
            }
               
        else
            {
            //allow deletion
            }

--
smau
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.