Link the DataField to the Recordset

Link the DataField to the Recordset

The data control allows you to quickly link controls and databases; however, not only is it far from flexible compared with the database-objects coding interface, it doesn’t look great. I use the latter solution and assume most VB programmers do. But it’s quite painful to add or alter several lines of code every time you put a new text field on a dialog. It’s a waste of the DataField property, however; it can be just as useful as the Tag property, and in this case, it’s more descriptive. So what if you write a few routines to simulate the data control’s basic operations through the DataField property? This simple routine loads data from a Recordset to all controls on a form:

 Public Sub ReadData(frm As Form, rc as Recordset)	Dim ctrl As Control	' Need to ignore errors on controls	' that don't support databinding.	On Error Resume Next	For Each ctrl In frm.Controls		If ctrl.DataField <> "" Then			ctrl = rc.Fields(ctrl.DataField)		End If	Next 'ctrlEnd Sub

You only need to put the field name into the DataField property of involved controls at design time. By altering such routines, you can achieve more complex data handling than if you use data controls, as well as make reading, writing, and validation a lot simpler than doing everything manually.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes