Looping through form controls and updating their properties
Posted on 2006-04-05
After a bit of searching I can't quite find a clear answer so thought I would ask the question (probably again, so apologies).
I have written a function that is intending to loop through the controls on a form to replace apostrophes with a safe version to aid with dynamic sql production (the sql bit isn't important, just context)
so here is the function:
Public Sub TextBoxQuotes(ByVal Parent As Object)
Dim c As Control
For Each c In Parent.Controls
If c.HasChildren Then
If TypeOf (c) Is TextBox Then
c.Text.Replace(Chr(39), Chr(96)) 'replace ' with `
Tracing through a run, the function is entered into and will step in correctly but the replace doesn't seem to do anything. I assume this is some schoolboy error on my part! I have tried ByRef and ByVal to no change and have wondered if i am somehow creating an instance of the control instead of actually updating the original.
Can anyone see why the replace isn't doing anything?
Any help would be appreciated