Custom Zoom Box to edit and display data using VBA

Custom Zoom Box to edit data using VBA

This article is about to design the custom Zoom In control for edit and save. When we design Form and want editing text in memo field or any field we can use Zoom in control for editing on the zooming window and also save the record. Using this technique we can comfortably add and remove text in zoom field otherwise simply cancel it.

For implementation of this technique firstly we have to add table to store and fetching data as shown in Fig 1.1.

Custom Zoom Box to edit and display data using VBA Fig-1.1

Fig-1.1

Then we have to create a Microsoft Access Form with control object and bound with table field as shown in Fig 1.2.

Custom Zoom Box to edit and display data using VBA Fig-1.2

Fig-1.2

Next we have to create another Access Form with textbox control and button control as shown in Fig 1.3. This Form is working like Zoom in Form when we are right click on main form.

Custom Zoom Box to edit and display data using VBA Fig-1.3

Fig-1.3

Then we have write function for zoom in functionality and call this function on main Form. Open the Form in Form view .Right click on Textbox field and select the Zoom option as shown in Fig 1.4.

Custom Zoom Box to edit and display data using VBA Fig-1.4

Fig-1.4

After selecting the Zoom option, a window will pop up for editing .We can change the text and after editing click on ok button .Automatically text data is saved as shown in Fig 1.5.

Custom Zoom Box to edit and display data using VBA Fig-1.5

Fig-1.5

VBA CODE :

Option Compare Database
Option Explicit
Public Function ZoomIN()
Dim VAL1
Dim HCONTROL As Control
Set HCONTROL = Screen.ActiveControl
VAL1 = Screen.ActiveControl.Value
DoCmd.OpenForm "ZOOMFORM", acNormal
With Screen.ActiveForm.Controls("TxtZoom")
.Value = VAL1
End With
End Function
Public Function ZoomOUT()

Dim txtZoom
Dim SCTRL As String
txtZoom = Forms("ZOOMFORM").Controls("txtZoom").Value
DoCmd.Close acForm, Screen.ActiveForm.Name
If Len(txtZoom) > 0 Then
Screen.ActiveControl.Value = txtZoom
End If
End Function

'call the function
Option Compare Database
Option Explicit
Private Sub cmdBTN_Click()

Dim VAR1
VAR1 = CloseZoom()
MsgBox ("SAVE")
End Sub


DISCLAIMER

It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. Access Guru will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.