Home  Fees/Services  Access 2010 Template  Access Tutorial  Access Download  Articles  Search  Contact  Privacy  Links

Active Field Labels For Sorting
Access Form Label Links






Visual Basic Tutorials:
Access-Google Earth
Age Calculation
Change To Proper Case
Email via Gmail #1
Send Gmail Email #2
Inactivity Logout Code
Outlook Email
Read Email Access
Email Attachment
Send Outlook Email
Running Sum
Denormalize Records
Stock Quotes
CreateQueryDef
Find Database Path
Detail-Master Update
Data Field Validation
Field Value New-Old
FindFirst
Access Version
Global Variable Parameter
Global Variables
Active Labels
Files List Box
Mail Merge
Quick Sort
Recordset Filters
Reference Form Field
Select Case
Access Transactions


Visual Basic Function Examples


Active Labels: Form Links Using Labels

To give your application more flexibility you can create links out of the labels on fields where appropriate. This is most useful when you have a dropdown list and the information you have to enter is not in the list.



Our programming team has 15 members containing a wide variety of technical database knowledge and programming experience. Experts in small business management and scientific database programming.

Did you know you don't need to move to SQL/Server to run and manage your Access database on the net. There are many alternative solutions. Among them are Amazon's AWS cloud services and various hosting services in nearly every state.


When this is the case, making the label of the list a link to an input form to enter the information needed is easy and user friendly. In this screen shot you see a form showing a Company drop down and a Contacts dropdown. The functionality is to select a Company from the list. If the company you need is not listed then you double click Company and a company input form pops up. When you have selected the company the Contacts dropdown lists contacts associated with that company. If your contact is not listed double click the Contacts label and enter the contact information.

Add Items to Drop down lists
The code to open the Contact form is in the 'On Double Click' event of the Contact Label. That code is:

Private Sub lblContact_DblClick(Cancel As Integer)
On Error GoTo Err_lblContact_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "CompanyContact"

stLinkCriteria = ""
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, , "Add"

Exit_lblContact_DblClick:
Exit Sub

Err_lblContact_DblClick:
MsgBox Err.Description
Resume Exit_lblContact_DblClick
End Sub

Note that on the form open a parameter of 'Add' is passed to the Contact form. This tells the form what function is needed so that it can set appropriate items in the 'On Open' event and when the form closes it can process appropriately. Here is the 'On Open' code:

Private Sub Form_Open(Cancel As Integer)

If Me.OpenArgs = "Tracking" Then
    txtCompanyLocationID.DefaultValue = [Forms]![CompanyTracking]![txtLocationID]
Else
    If Me.OpenArgs = "Add" Then
        txtCompanyLocationID.DefaultValue = [Forms]![Inquiry]![cmbCompanyLocationID]
    End If
    If Me.OpenArgs = "AddReg" Then
    txtCompanyLocationID.DefaultValue = [Forms]![Registration]![cmbCompanyLocationID]
    End If
    If Me.OpenArgs = "AddDetails" Then
        txtCompanyLocationID.DefaultValue = [Forms]![InquiryDetails]![cmbCompanyLocationID]
    End If
End If
End Sub


When the Contacts input form pops up enter the information for the new contact:

Active Labels for Dynamic Forms

Now when you are done and you close the Contact form the 'On Close' event processes.

Private Sub Form_Close()
On Error GoTo Error_Handler

If Me.OpenArgs = "Tracking" Then
    Forms!CompanyTracking!subCompanyLocations.Requery
    Forms!CompanyTracking!subContacts.Requery
Else
    If Me.OpenArgs = "Add" Then
        Forms!Inquiry!cmbContacts = Me!ContactID
        Forms!Inquiry!cmbContacts.Requery
        Forms!Inquiry!subContactInfo.Requery
    End If
    If Me.OpenArgs = "AddReg" Then
        Forms!Registration!cmbContacts = Me!ContactID
        Forms!Registration!cmbContacts.Requery
    End If
    If Me.OpenArgs = "AddDetails" Then
        Forms!InquiryDetails!cmbContacts = Me!ContactID
        Forms!InquiryDetails!cmbContacts.Requery
    End If
End If

Exit Sub

Error_Handler:
If Err.Number = 2450 Then
    Resume Next
Else
    MsgBox "Unexpected error on close of form Company Contact."
End If
End Sub

Note that the code in the if statement 'If Me.OpenArgs = "Add" Then' sets the item you have entered in the list on the calling form. Now when you return what you have added is displayed in the drop down list.

Labels as Links on Access Forms
 

Select that entry and the information you entered floods into the form:

label double click event










Blue Claw Database Design Downloadable Tutorial:
TransferText & OutputTo Microsoft Access Download.  








A Blue Claw Software Design Template:

Work Order Administration Software
 










A Blue Claw Database Design Article:

Software Risk Assessment
 

Microsoft Office:
MS Access 2000 Through 2016 and Office 365 & Sharepoint


Contact Information

Copyright 2000-2017 Blue Claw Database Design

Microsoft Access 2007, 2010, 2013 & 2016