Randomblink
The Irreverent Reverend
- Local time
- Today, 14:56
- Joined
- Jul 23, 2001
- Messages
- 279
Can someone help me please?
I am wondering if there is a trick to this...
Something that will make this easier for my code-jumbled brain to understand or use...
I have been given the following code...(by The_Doc_Man)
Private Function GetUserDepartment(sUser As String)
Dim sDept As Integer
sDept = DLookup("[DEPT_ID]", "tbl_Employee", "[Empl_NTLogon]='" & sUser & "'")
GetUserDepartment = DLookup("[DEPT_NAME]", "tbl_Department", "[DEPT_ID]=" & sDept & "")
End Function
I am trying to genericize it (yes, I just made up a word!)...
I want to recreate what this Function above does, but NOT restrict it to looking for the UserDepartment...
I am slowly piecing something together like below...
Private Function UserDetails(trgt_tbl As String, trgt_tbl_fld As String, trgt_tbl_crit As String, trgt_scent As String, trgt As Variant, fnd_tbl As String, fnd_tbl_fld As String)
' trgt_tbl = tbl_Employee
' trgt_tbl_fld = DEPT_ID
' trgt_tbl_crit = Empl_NTLogon
' trgt_scent = sUser
' trgt = sDept
' fnd_tbl = tbl_Department
' fnd_tbl_fld = DEPT_NAME
' trgt_tbl_fld = DEPT_ID
' Function that grabs the needed data GetUserDepartment
trgt_scent = GetNTUser
trgt = DLookup(trgt_tbl_fld, trgt_tbl, "trgt_tbl_crit&""='" & trgt_scent & "'")
GetUserDepartment = DLookup(fnd_tbl_fld, fnd_tbl, "trgt_tbl_fld & "=" & trgt & "")
End Function
When it dawns on me...
Having had no formal training in VB, excluding a class at the local community college by an imbecile, I am not sure if there is a standard way of putting something like this into action...
If you can help me, I would appreciate it...
I am wondering if there is a trick to this...
Something that will make this easier for my code-jumbled brain to understand or use...
I have been given the following code...(by The_Doc_Man)
Private Function GetUserDepartment(sUser As String)
Dim sDept As Integer
sDept = DLookup("[DEPT_ID]", "tbl_Employee", "[Empl_NTLogon]='" & sUser & "'")
GetUserDepartment = DLookup("[DEPT_NAME]", "tbl_Department", "[DEPT_ID]=" & sDept & "")
End Function
I am trying to genericize it (yes, I just made up a word!)...
I want to recreate what this Function above does, but NOT restrict it to looking for the UserDepartment...
I am slowly piecing something together like below...
Private Function UserDetails(trgt_tbl As String, trgt_tbl_fld As String, trgt_tbl_crit As String, trgt_scent As String, trgt As Variant, fnd_tbl As String, fnd_tbl_fld As String)
' trgt_tbl = tbl_Employee
' trgt_tbl_fld = DEPT_ID
' trgt_tbl_crit = Empl_NTLogon
' trgt_scent = sUser
' trgt = sDept
' fnd_tbl = tbl_Department
' fnd_tbl_fld = DEPT_NAME
' trgt_tbl_fld = DEPT_ID
' Function that grabs the needed data GetUserDepartment
trgt_scent = GetNTUser
trgt = DLookup(trgt_tbl_fld, trgt_tbl, "trgt_tbl_crit&""='" & trgt_scent & "'")
GetUserDepartment = DLookup(fnd_tbl_fld, fnd_tbl, "trgt_tbl_fld & "=" & trgt & "")
End Function
When it dawns on me...
Having had no formal training in VB, excluding a class at the local community college by an imbecile, I am not sure if there is a standard way of putting something like this into action...
If you can help me, I would appreciate it...