Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string in command 1

Status
Not open for further replies.

andzejek

MIS
Sep 1, 2007
154
US
Hi!

How to replace portion of command with a string. Here is the code:

dim myStr as string
myStr="5"

me.textbox&myStr..setfocus - this works in VFP, but how to

make it works in MsAccess?
 
Do you want to put the contents of myStr into the textbox then set focus to that textbox?

If so:
Code:
Dim myStr As String

myStr = "5"
Me.Textbox.Text = myStr
Me.Textbox.SetFocus

If I have misunderstood your request, can you explain please?

John
 
Yes you did.
I want to be able to set focus(or something else) to different controls of which names I don't know at design time. Name of these controls will determined at run time.

Andrew
 
Andrew,

If I've understood correctly I think you probably want to do something like this:

Code:
   '...controls have already been created, strCtrlName declared and contains name of control you wish to set focus to
   Me.Controls(strCtrlName).SetFocus

Ed Metcalfe

Please do not feed the trolls.....
 
Ok, thank you; I will try this and get back to you later today.
 
hi!
Ok, it is working for setfocus, but why it does not working for enable - error message "object does not support this method or property
 
You don't have to set the focus in order to set the value of a control. Setting the focus is only required if you want to update the text property. This is rarely used since the default is to set the Value property.

There is no "enable" property. I think you want something like:
Code:
Me(strCtrlName).Enabled =  True

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Or it could be that the control type you are working with cannot be enabled/disabled...

Also remember that a control cannot be disabled whilst it has focus.

Ed Metcalfe.

Please do not feed the trolls.....
 
this same error message!

I know about focus and enabling/disabling controls. All I want to do is dynamically(depend on conditions) change properties of some labels and textboxes.

Thanks!
 
Post you code.

Ed Metcalfe.

Please do not feed the trolls.....
 
dim myStr as string
dim strCtrlName as control

for n=3 to 7
myStr=trim(str(n))
strCtrlName="textbox" & myStr
Me(strCtrlName).Enabled = True
next n
 
Replace this:
dim strCtrlName as control
with this:
Dim strCtrlName As String
Dim n As Integer

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top