Help update code to access 2007

D

directions

I have vba code that has worked from access 97 - access 2003. It now
fails in access 2007. I hope that I'm missing something simple...

I'm modifying the borderwidth and bordercolor of various controls on
various forms - so I created a function in a module to do the job for
me. The code has a lot of other stuff in it - but here's where I'm
running into problems.

public function myFunction (ctl as control, intWidth as integer)

ctl.borderwidth = intWidth

end function


The problem:

In Access 2007, the control object no longer has any border properties
associated with it... There must be a better way to do this besides
duplicating my code for all of the different types of controls
(textbox, combobox, listbox, etc...)

Please also let me know if there is a simple .Net solution to this
problem. I have VS2005 and also program in VB.Net and C#.Net.

Thanks!
 
M

Maurice

Maybe I don't get it but if I enumerate through the controls I can set the
borderwith at runtime.

example:

dim ctl as control

for each ctl in me
ctl.borderwidth=2 (or intWidth)
next

works as expected...

If you are saying that there isn't any intellisense that's correct. The
borderwidth won't show up but if you just type it, it will be recognized as
correct.

Now back to the original problem. The fact that your code doesn't work
doesn't have to be that specific part. Could it be something else? Do you get
an error message.
 
D

directions

I'm getting an error that borderwidth is not a valid property and the
rest of the code runs fine when that line is commented out. Maybe the
difference is that I'm not using "Me" - I'm passing the form as a
parameter and then iterating through the controls. I've looked at the
object reference for Control and borderwidth is not a valid
property... What am I missing?
 
M

Maurice

Correct, you won't find it inthe object reference but if you type it will be
accepted. The me is just lazy programming it refers to the actual form where
i place the code.

Could you provide a piece of your code so we can take a look at it. Maybe
your parameter isn't set correctly.
 
D

directions

Here's a code snippet. All of the border properties fail with an
error that it's not a valid property.

Public Sub ctlEnabler(frmSource As Form, intNumber As Integer,
Optional vntBorderWidth As Variant, Optional vntColor As Variant)
'enable / disable controls on a form
Dim ctlEnabler As Control
Dim vntEnabler As Variant
Dim blnSkipBorder As Boolean
Dim blnSkipAll As Boolean


For Each ctlEnabler In frmSource.Controls
blnSkipBorder = False
blnSkipAll = False

ctlEnabler.Enabled = True

If blnSkipAll = False Then
ctlEnabler.SpecialEffect = 0
ctlEnabler.BorderColor = 0

If Not blnSkipBorder Then
ctlEnabler.BorderWidth = 0
ctlEnabler.BorderStyle = 1
End If

If vntEnabler = intNumber Then
If IsMissing(vntColor) Then
ctlEnabler.BorderColor = 16711680 'blue
Else
ctlEnabler.BorderColor = vntColor
End If

If IsMissing(vntBorderWidth) And Not blnSkipBorder
Then
ctlEnabler.BorderWidth = 4
ElseIf Not blnSkipBorder Then
ctlEnabler.BorderWidth = CInt(vntBorderWidth)
End If
End If
End If
End If
Next

Exit Sub
End sub
 
D

directions

I think I've got it figured out. I needed to pass the form as a
reference (byref). When I do this, it works just fine.

Thanks for the second set of eyes. I knew that I was missing
something simple.
 

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