The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Question
Posted: 16 Jan 08 3:50 PM
|
Having trouble with the following function, says there is a problem near my End With... Any Ideas?
Thank You,
Sub PopulateEmp(Sender) Dim strQ Dim strC Dim oShell Dim tUserID Dim tAccountID Dim tCreateUser Dim tModifyUser
tUserID = application.basicfunctions.CurrentUserID tAccountID = frmAccountDetail.CurrentID tCreateUser = application.basicfunctions.CurrentUserID tModifyUser = application.basicfunctions.CurrentUserID
Set rs = CreateObject("ADODB.Recordset") With rs Set .ActiveConnection = Application.GetNewConnection .CursorLocation = adUseClient .CursorType = adOpenStatic .LockType = adLockOptimistic .Open "select * from EMPLOYEE where ACCOUNTID = '" & tAccountID & "'"
If .RecordCount = 1 Then tbxEmployeeTotal.Text = .Fields("EMPLOYEETOTAL").Value Else IF .RecordCount = 0 Then tbxEmployeeTotal.Text = "" End If
.Close End With Set rs = Nothing
End Sub |
|
|
|
Re: Question
Posted: 16 Jan 08 4:00 PM
|
In VBScript, "Else If" is one word, as in "ElseIf". That is your problem.
Change this:
If .RecordCount = 1 Then tbxEmployeeTotal.Text = .Fields("EMPLOYEETOTAL").Value Else IF .RecordCount = 0 Then tbxEmployeeTotal.Text = "" End If
to this:
If .RecordCount = 1 Then tbxEmployeeTotal.Text = .Fields("EMPLOYEETOTAL").Value ElseIf .RecordCount = 0 Then tbxEmployeeTotal.Text = "" End If
-Ryan |
|
|
|
Re: Question
Posted: 16 Jan 08 4:11 PM
|
DOH!!! Now I feel a little like a dull tool in a shed.
Thank you for the answer.
|
|
|
|
Re: Question
Posted: 16 Jan 08 4:14 PM
|
Here is another question, How would I lock down certain parts of a form so only certain people can change the values of those fields? |
|
|
|
Re: Question
Posted: 17 Jan 08 12:19 AM
|
Use field level security through the Admin tool.
If it is a form based on a one to many table or does not have field level security enabled on the base table you can build a permissions control panel (or simply place a flag of some kind in the custom user text fields in admin - these are stored in userprofile) and then set the control's enabled property to false if they don't have permission.
For appearance's sake, if you have the option of grouping the controls together, you can set them on a panel and set that panel's readonly property (IIRC - may be the enabled property) to true/false (depending on if it is readonly or enabled), which will then make any controls on the panel follow that model WITHOUT making the text of certain controls appear grayed out (like setting enabled=false on edit and picklist controls does) |
|
|
|