changing a property for a control in code

H

Helen Martin

I want to create a command button on my form that will change the
properties of a control...

I have a form that has 4 controls in kind of a table format...

I tab through the controls doing data entry...

sometimes I am only entering two of the fields...
sometimes I am entering all four...

I'd like my command button to change the tab stop property for two of
the fields to NO when I am entering only two fields..

I can create the button, and get the module started, but I'm not sure
how to refer to the property of the control..

my first control is called [lot number] the second is called
[lot description] but I do not know now to refer to the property of
each that is called Tab stop..

I looked up up Chaning control properties in VB Code in the help and it
seems to say I should be able to do it something like this.. however
every way I try it causes the same error..

here is my code
=============
Private Sub All_tabs_Click()
Forms![items purchased].[lot number].[tab stop] = True
Forms![items purchased]![lot description].[tab stop] = True
End Sub

or.. they recommend this as faster..

Private Sub All_tabs_Click()
Me.[lot number].[tab stop] = True
Me![lot description].[tab stop] = True
End Sub

--------

or the help seemed to say I could just have a button that toggled the
tabs with code that looked something like

Private Sub Toggle_tabs_Click()
With Me![lot number]
.[tab stop]= Not .[tab stop]
End With
With Me![lot description]
.[tab stop]= Not .[Tab stop]
End With
End Sub

=================

however, every way I do it I get Error 438 which says this what I've
quoted below, which is way over my head... I have no idea what a Friend
procedure is or a Late bound call..

==============
Error 438

Not all objects support all properties and methods. This error has the
following cause and solution:

· You specified a method or property that doesn't exist for this
Automation object.

See the object's documentation for more information on the object and
check the spellings of properties and methods.

· You specified a Friend procedure to be called late bound.

The name of a Friend procedure must be known at compile time. It can't
appear in a late-bound call.

For additional information, select the item in question and press F1.

I've done only a little programming before and suspect I have it either
completely wrong, or only a tiny bit wrong..

I'd appreciate any help!
Helen
 
M

Marshall Barton

Helen said:
I want to create a command button on my form that will change the
properties of a control...

I have a form that has 4 controls in kind of a table format...

I tab through the controls doing data entry...

sometimes I am only entering two of the fields...
sometimes I am entering all four...

I'd like my command button to change the tab stop property for two of
the fields to NO when I am entering only two fields..

I can create the button, and get the module started, but I'm not sure
how to refer to the property of the control..

my first control is called [lot number] the second is called
[lot description] but I do not know now to refer to the property of
each that is called Tab stop..

I looked up up Chaning control properties in VB Code in the help and it
seems to say I should be able to do it something like this.. however
every way I try it causes the same error..

here is my code
=============
Private Sub All_tabs_Click()
Forms![items purchased].[lot number].[tab stop] = True
Forms![items purchased]![lot description].[tab stop] = True
End Sub

or.. they recommend this as faster..

Private Sub All_tabs_Click()
Me.[lot number].[tab stop] = True
Me![lot description].[tab stop] = True
End Sub

--------

or the help seemed to say I could just have a button that toggled the
tabs with code that looked something like

Private Sub Toggle_tabs_Click()
With Me![lot number]
.[tab stop]= Not .[tab stop]
End With
With Me![lot description]
.[tab stop]= Not .[Tab stop]
End With
End Sub

=================

however, every way I do it I get Error 438

Property names do not have spaces in them. Use TabStop.
 
H

Helen Martin

Marshall said:
Private Sub Toggle_tabs_Click()
With Me![lot number]
.[tab stop]= Not .[tab stop]
End With
With Me![lot description]
.[tab stop]= Not .[Tab stop]
End With
End Sub

=================

however, every way I do it I get Error 438

Property names do not have spaces in them. Use TabStop.

wonderful!!
it works now..
thank you Marshall...
Helen
 
H

Helen Martin

Helen said:
Marshall said:
Private Sub Toggle_tabs_Click()
With Me![lot number]
.[tab stop]= Not .[tab stop]
End With
With Me![lot description]
.[tab stop]= Not .[Tab stop]
End With
End Sub

=================

however, every way I do it I get Error 438

Property names do not have spaces in them. Use TabStop.

wonderful!!
it works now..
thank you Marshall...
Helen

one more question...

my problem now is that the focus changes from the data entry control
where it was before, to the "toggle tabs" button... but I want it to
stay in the data entry form..

I'm guessing I have to set something like a bookmark to mark where I was
when I clicked the button, and then set the focus back to that mark
after I click the button...

or is there something I can do to prevent it from getting the focus when
I click it...??

Helen
 
M

Marshall Barton

Helen said:
my problem now is that the focus changes from the data entry control
where it was before, to the "toggle tabs" button... but I want it to
stay in the data entry form..

I'm guessing I have to set something like a bookmark to mark where I was
when I clicked the button, and then set the focus back to that mark
after I click the button...

or is there something I can do to prevent it from getting the focus when
I click it...??


If the button and the text boxes are in the same form, then
you can use a label control instead of a button. Unattached
labels can not receive the focus, but they fo have the Click
event.

Set the label's SpecialEffect property to Raised so it looks
similar to a button. If you want a visual effect when you
click the label, you can toggle its SpecialEffect property:

If Me.Toggle_tabs.SpecialEffect = 1 Then
Me.Toggle_tabs.SpecialEffect = 2
Else
Me.Toggle_tabs.SpecialEffect = 1
End If

Or,more obscure, but fewer lines:

Toggle_tabs.SpecialEffect = 3 - Toggle_tabs.SpecialEffect
 

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