Archive

Posts Tagged ‘MS Access’

MS Access: HTML Editor control to use in forms

February 10th, 2011 5 comments

If you want to get HTML editor within MS Access form, there are couple of solutions available. The free solution I know is to get Not So Elegant HTML Editor. The problem with this editor is that

  • After looking at this editor, you will never say “so cool”
  • It is good for basic editing but many important functionality like “Table” editing is missing.

When I had to create HTML Editor within MS Access form, I asked the question to myself “Why to reinvent the wheel?” and the solution I came up with has the main benefits

  • It is completely FREE
  • When users will look at it, they will definitely say “so cooooool”.
  • Rich feature set
  • XHTML compliant code will be generated and hence output can be used anywhere.
  • Plugin based architecture can help add extra cool features

Here is a sample of how this editor would look like Read more…

MS Access VBA: Get/set Javascript Variable in Microsoft Web Browser ActiveX Control

February 5th, 2011 1 comment

In your MS Access application, if you are using Microsoft Web browser, we may have to interact with the Javascript variable inside the loaded page. There is no obvious method exists in the Web browser control but using the following trick you can get/set the Javascript variable in the webpage.

Quick Tip:

Add Javascript function to get/set the value of Javascript variable/ HTML element from/to the hidden field. Execute the function using VBA code with the help of DOM functions available in VBA. Please read further for the details or download the code. Read more…

MS Access: Check If The Normal Form Or Subform Form Is Loaded

April 18th, 2008 1 comment

If you need to check if MS Access form is loaded or not, you can easily check it using the folloing code

If CurrentProject.AllForms("FORMNAME").IsLoaded = True Then
	' DO SOMETHING
End If

This code is good until you are using single form application. This code will fail if the form is used as subform. To search all the forms including subform, I have created a function calling which will search for all the loaded forms and gives the result as boolean value. Here is the example to check if the form is loaded or not

Dim IsLoaded as Boolean
IsLoaded = IsFormLoaded("FORMNAME")

The function IsFormLoaded will search each and every control within each form to find the form FORMNAME. Of course, this is a overhead to the application so to reduce the amount of search, two optional arguments can be provided which can be very helpful in searching subform. If you already know the parent form name of the subform and the controlname which holds subform within parent form, the time to search subform will be reduced. For example

Dim IsLoaded as Boolean
IsLoaded = IsFormLoaded("FORMNAME","PARENTFORMNAME")

will search all the controls withing PARENTFORMNAME form while

Dim IsLoaded as Boolean
IsLoaded = IsFormLoaded("FORMNAME","PARENTFORMNAME","CONTROLNAME")

will search for the CONTROLNAME control within PARENTFORMNAME form to check if the FORMNAME form is loaded.

The above mentioned functions are here.

Public Function IsFormLoaded(strFormName As String,
		Optional LookupFormName As Form,
		Optional LookupControl As Control) As Boolean
    Dim frm As Form
    Dim bFound As Boolean

    If Not (IsMissing(LookupFormName) Or IsNull(LookupFormName)
		Or LookupFormName Is Nothing) Then
        If Not (IsMissing(LookupControl) Or IsNull(LookupControl)
 		Or LookupControl Is Nothing) Then
        On Error GoTo ErrorHandler:
            If LookupControl.ControlType = acSubform Then
                If LookupControl.Form.Name = strFormName Then
                    bFound = True
                End If
            End If
        Else
            Call SearchInForm(LookupFormName, strFormName, bFound)
        End If
    Else
        For Each frm In Forms
            If frm.Name = strFormName Then
                bFound = True
                Exit For
            Else
                Call SearchInForm(frm, strFormName, bFound)
                If bFound Then
                    Exit For
                End If
            End If
        Next
    End If
ErrorHandler:
    IsFormLoaded = bFound
End Function

Public Function SearchInForm(frm As Form, strDoc As String,
 			bFound As Boolean)
On Error GoTo ErrorHandler
    Dim ctl As Control

    For Each ctl In frm.Controls
        If ctl.ControlType = acSubform Then
            If ctl.Form.Name = strDoc Then
            'If ctl.SourceObject = strDoc Then
                bFound = True
            Else
                Call SearchInForm(ctl.Form, strDoc, bFound)
            End If
SkipElement:
            If bFound Then
                Exit For
            End If
        End If
    Next
    Exit FunctionErrorHandler:
            Resume SkipElement
End Function