Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Forms in Access - Control Captions and Control Properties

Status
Not open for further replies.

NiallWestland1974

Programmer
Oct 22, 2003
7
GB
Hi,
I'm trying to dynamically capture the captions of the forms contained in a form and, in addition, set the onchange property of these controls dynamically through VBA.

Does anyone have any ideas on how to solve either (or even one!) of these problems??

The (faulty!) code is:
For i = 0 To Me.Count - 1
If TypeOf Me(i) Is TextBox Then
If i = 0 Then
strTextBoxName = Me(i).Caption
Else
strTextBoxContent = strTextBoxContent & "," & Me(i).Caption
End If
End If
Next i

Thanks
 
D'oh - I have the caption problem sorted out - by looking for labels rather than textboxes, the code above basically works:

For i = 0 To Me.Count - 1
If TypeOf Me(i) Is Label Then
If i = 1 Then
AlterTextBox = "Date altered: " & Now() & " - " & Me(i).Caption
Else
AlterTextBox = AlterTextBox & "," & Me(i).Caption
End If
End If
Next i
MsgBox AlterTextBox

HOWEVER, does anyone know if you can add event properties to form controls at run-time?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top