Code assistance

  • Thread starter Thread starter ladybug via AccessMonster.com
  • Start date Start date
L

ladybug via AccessMonster.com

I have the following code on Before Update of a Form:


If Me.Frame14 = 2 Then
Me.CommentsReasons.Visible = True
Else
Me.CommentsReasons.Visible = False
End If
If Me.Frame14 = 2 Then
Me.DescofChange.Visible = True
Else
Me.DescofChange.Visible = False
End If
If Me.Frame37 = 2 Then
Me.CommentsReasons2.Visible = True
Else
Me.CommentsReasons2.Visible = False
End If
If Me.Frame37 = 2 Then
Me.DescofChange2.Visible = True
Else
Me.DescofChange2.Visible = False
End If

I had the frame14 in there previously and it worked just fine. I made the
addition of Frame37 to the form and now I get an error and it highlights
..Visible =
under the section for Frame37

Can someone help me uderstand where I am going wrong with this code. Sorry,
vba is not in my vocabulary
 
You don't mention which of the two "Frame37" IF statements is giving you the
error, nor whether it is the = True or = False portion that is breaking.

This is only a stylistic suggestion, so if it isn't your style, don't
bother...

You might also do what you've described with something like:

Dim blnVisible as Boolean

blnVisible = (Me.Frame14 = 2) Or (Me.Frame37 = 2)

Me.CommentsReasons.Visible = blnVisible
Me.DescofChange.Visible = blnVisible


Regards

Jeff Boyce
Microsoft Office/Access MVP
 
I think your code could work,
However I need to separate it somehow so if Frame14=2 then
Me.CommentsReasons.Visible = blnVisible
Me.DescofChange.Visible = blnVisible

Then if Frame37=2
Me.CommentsReasons2.Visible = blnVisible
Me.DescofChange2.Visible = blnVisible

How do I do that? There are two sets of Comments and Description of Changes.

Jeff said:
You don't mention which of the two "Frame37" IF statements is giving you the
error, nor whether it is the = True or = False portion that is breaking.

This is only a stylistic suggestion, so if it isn't your style, don't
bother...

You might also do what you've described with something like:

Dim blnVisible as Boolean

blnVisible = (Me.Frame14 = 2) Or (Me.Frame37 = 2)

Me.CommentsReasons.Visible = blnVisible
Me.DescofChange.Visible = blnVisible

Regards

Jeff Boyce
Microsoft Office/Access MVP
I have the following code on Before Update of a Form:
[quoted text clipped - 27 lines]
Sorry,
vba is not in my vocabulary
 
The same error is happening with your code. It is occuring at:

blnVisible = (Me.Frame37 = 2)

Me.CommentsReasons2.Visible = blnVisible
Me.DescofChange2.Visible = blnVisible

the ".Visible =" after Me.CommentsReasons2 is what is being highlighted in
yellow

Jeff said:
You don't mention which of the two "Frame37" IF statements is giving you the
error, nor whether it is the = True or = False portion that is breaking.

This is only a stylistic suggestion, so if it isn't your style, don't
bother...

You might also do what you've described with something like:

Dim blnVisible as Boolean

blnVisible = (Me.Frame14 = 2) Or (Me.Frame37 = 2)

Me.CommentsReasons.Visible = blnVisible
Me.DescofChange.Visible = blnVisible

Regards

Jeff Boyce
Microsoft Office/Access MVP
I have the following code on Before Update of a Form:
[quoted text clipped - 27 lines]
Sorry,
vba is not in my vocabulary
 
It sounds like Access can't figure out what CommentsReasons2 is. Can you
confirm exact spelling for this control's name?

What is the error message?

Regards

Jeff Boyce
Microsoft Office/Access MVP


ladybug via AccessMonster.com said:
The same error is happening with your code. It is occuring at:

blnVisible = (Me.Frame37 = 2)

Me.CommentsReasons2.Visible = blnVisible
Me.DescofChange2.Visible = blnVisible

the ".Visible =" after Me.CommentsReasons2 is what is being highlighted in
yellow

Jeff said:
You don't mention which of the two "Frame37" IF statements is giving you
the
error, nor whether it is the = True or = False portion that is breaking.

This is only a stylistic suggestion, so if it isn't your style, don't
bother...

You might also do what you've described with something like:

Dim blnVisible as Boolean

blnVisible = (Me.Frame14 = 2) Or (Me.Frame37 = 2)

Me.CommentsReasons.Visible = blnVisible
Me.DescofChange.Visible = blnVisible

Regards

Jeff Boyce
Microsoft Office/Access MVP
I have the following code on Before Update of a Form:
[quoted text clipped - 27 lines]
Sorry,
vba is not in my vocabulary
 
I doubled check the name you were right! I was so concerned over the Visible
part since that was what was highlighted. Thank you so much for your help!

Jeff said:
It sounds like Access can't figure out what CommentsReasons2 is. Can you
confirm exact spelling for this control's name?

What is the error message?

Regards

Jeff Boyce
Microsoft Office/Access MVP
The same error is happening with your code. It is occuring at:
[quoted text clipped - 32 lines]
 
Back
Top