Use a Control's Datasheet Caption or Associated Table Column in VBA

padlocked17

Registered User.
Local time
Today, 09:45
Joined
Aug 29, 2007
Messages
275
Just as the title describes, I want to include either the Datasheet Caption or the column caption for the associated control in VBA.

I've got the following that is located in a module as a public function.

Code:
    Dim ctl As Control
    Dim Num As Integer
    If Num = 1 Then
        MsgBox "Data is required in " & ctl.Name & "," & vbCr & _
        "please ensure this is entered.", _
        vbInformation, "Required Data..."
        RequiredData = True
    Else

I want ctl.Name to show the caption for that control which is stored in the Datasheet Caption field OR the column caption for that control
 
Your code will never produce any output in the If part of your function. Because Num inititialises to 0. You have dimensioned ctl to control but never inititialised it to an actual control. If you want to show the caption of a control, you should use the caption property and not the name.

HTH:D
 

Users who are viewing this thread

Back
Top Bottom