Code Snippets
In all the times I have spent participating in forum discussions about all sorts of users' questions, I have learnt a great deal from all the participants.
I have decided to post some of the sample codes that I found users were asking for almost all the time to help me keep them in one place and to make it easier for me to share them again and again.
Hope you find them useful.
Get Subform Control Name
Here's another classic from fellow MVP, Leigh Purvis (LPurvis). This function returns the name of the subform control that contains the form passed as argument or the one running it (if no argument was passed).
Function fGetCurrentSubformName(Optional frmSub As Access.Form) As String
'Returns the name of the containing subform control
On Error Resume Next
Dim ctl As Access.Control
Dim strDummy As String
If frmSub Is Nothing Then
'No form passed, assume a control in the subform has focus
Set frmSub = Screen.ActiveControl.Parent
End If
strDummy = frmSub.Parent.Name
If Err <> 2452 Then
'Form has parent
For Each ctl In frmSub.Parent.Controls
If ctl.ControlType = acSubform Then
If ObjPtr(ctl.Form) = ObjPtr(frmSub) Then
If Err = 0 Then
fGetCurrentSubformName = ctl.Name
End If
End If
End If
Next
End If
End Function
Contents
- Generate GUIDs
- Backup and Compact BE
- Get E-mail Address from AD
- Get Network Username
- Leigh's Generic Recordset
- Trim Inner Spaces
- Get Subform Control Name
- The Opposite of DSum()
- Concatenate Records
- Get Network Domain Name
- Get Computer Name
- Get BE Info
- Execute Action Queries
- Extract Email Address