G
Gren
Using an example from a post, I'm trying to tweak this code to work with my
situation.
I only want specific people to be able to edit fields on my form.
I get a 'unterminated line error' on line 21.
I'm really trying to learn vbscript on the fly, so please be patient with my
questions and silly mistakes.
Here's my form:
Sub Item_Open()
'String of usernames allowed to access administrative fields
Const ALLOWED_USERS = "gren;zeiram"
'Define control names
Const FORM_NAME = "Provider Add/Change Form"
Const FIELD_NAME1 = "groupdate"
Const FIELD_NAME2 = "groupcastenter"
Const FIELD_NAME3 = "imagedate"
Const FIELD_NAME4 = "imagecastenter"
'Handle errors
On Error Resume Next
'Get the form
Dim oForm: Set oForm = Item.GetInspector.ModifiedFormPages(FORM_NAME)
If (Err.Number <> 0) Then
Call MsgBox("Could not find form named '" & FORM_NAME & "'. Please
check and try again", vbCritical, "Error")
Exit Sub
End If
'Get the fields
Dim oField1,
Set oField1 = oForm.Controls(FIELD_NAME1),
Dim oField2,
Set oField2 = oForm.Controls(FIELD_NAME2),
Dim oField3,
Set oField3 = oForm.Controls(FIELD_NAME3),
Dim oField4,
Set oField4 = oForm.Controls(FIELD_NAME4),
If (Err.Number <> 0) Then
Call MsgBox("Could not find control named '" & DD_NAME & "'. Please
check and try again", vbCritical, "Error")
Exit Sub
End If
'Get the username of the windows user currently logged in
Dim oWsNetwork: Set oWsNetwork = CreateObject("WScript.Network")
Dim strUsername: strUsername = oWsNetwork.UserName
Set oWsNetwork = Nothing
If (Err.Number <> 0) Then
Call MsgBox("Error occured when trying to get windows username",
vbCritical, "Error")
Exit Sub
End If
situation.
I only want specific people to be able to edit fields on my form.
I get a 'unterminated line error' on line 21.
I'm really trying to learn vbscript on the fly, so please be patient with my
questions and silly mistakes.
Here's my form:
Sub Item_Open()
'String of usernames allowed to access administrative fields
Const ALLOWED_USERS = "gren;zeiram"
'Define control names
Const FORM_NAME = "Provider Add/Change Form"
Const FIELD_NAME1 = "groupdate"
Const FIELD_NAME2 = "groupcastenter"
Const FIELD_NAME3 = "imagedate"
Const FIELD_NAME4 = "imagecastenter"
'Handle errors
On Error Resume Next
'Get the form
Dim oForm: Set oForm = Item.GetInspector.ModifiedFormPages(FORM_NAME)
If (Err.Number <> 0) Then
Call MsgBox("Could not find form named '" & FORM_NAME & "'. Please
check and try again", vbCritical, "Error")
Exit Sub
End If
'Get the fields
Dim oField1,
Set oField1 = oForm.Controls(FIELD_NAME1),
Dim oField2,
Set oField2 = oForm.Controls(FIELD_NAME2),
Dim oField3,
Set oField3 = oForm.Controls(FIELD_NAME3),
Dim oField4,
Set oField4 = oForm.Controls(FIELD_NAME4),
If (Err.Number <> 0) Then
Call MsgBox("Could not find control named '" & DD_NAME & "'. Please
check and try again", vbCritical, "Error")
Exit Sub
End If
'Get the username of the windows user currently logged in
Dim oWsNetwork: Set oWsNetwork = CreateObject("WScript.Network")
Dim strUsername: strUsername = oWsNetwork.UserName
Set oWsNetwork = Nothing
If (Err.Number <> 0) Then
Call MsgBox("Error occured when trying to get windows username",
vbCritical, "Error")
Exit Sub
End If