Refering to control property on a form in VB

D

david.lauberts

Hi

I am trying to simply my code in a application by using a sub routine
to amend the control properties of a form but I can't seem to get
basic to accept the control property being sent to the routine as a
string

The code I am using is :

Private Sub lSubControlPropertySet(stForm As String, stControl As
String, stProperty As string, varValue As Variant)

If IsNull(varValue) = True Then
Forms(stForm)(stControl)(stProperty) = ""
Else
Forms(stForm)(stControl)(stProperty) =
varValue
End If
end sub

But access says it can't find the field, control or property name.
However the following works

Private Sub lSubControlPropertySet(stForm As String, stControl As
String, stProperty As string, varValue As Variant)

If IsNull(varValue) = True Then
Forms(stForm)(stControl).RowSource= ""
Else
Forms(stForm)(stControl).RowSource=
varValue
End If
end sub

I think I am referring or declaring the property element incorrectly
( I have tried using an property value (eg 3 for ControlSource) but
don't know exactly how to do it. Hope someone can help

Regards
Dave
 
D

Dave

Dear Doug

For the record your answer works perfectly.

Your advice is always appreciated, many thanks for taking the time to
respond and help

Regards
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top