Problem with my code, any ideas?

S

SRT

Hi,

I have the following code below, which works if I do the following

Call No1
'Call No2
Exit Sub

For whatever reason it fails at Me![Passwords2].SetFocus at the end of Sub
No2 with

Run-time Error '2110' - Unable to goto control

Any Ideas?

CODE:

Call No1
Call No2
Exit Sub

Sub No1()
strTest = Shell("C:\Program Files\MyApp\myapp.exe", 1)
sSleep (100)
AppActivate strTest
SendKeys ("12345"), True
SendKeys ("{Tab}{Enter}{Tab}"), True
For intA = 1 To 20
SendKeys ("+{Down}"), True
Next intA
SendKeys ("^(c)"), True
SendKeys "(%{F4})", True
AppActivate "Microsoft Access"
Me![Password1].SetFocus
SendKeys ("^(v)"), True
SendKeys ("{Tab}")

End Sub


Sub No2()
strTest = Shell("C:\Program Files\MyApp\myapp.exe", 1)
sSleep (100)
AppActivate strTest
SendKeys ("12345"), True
SendKeys ("{Tab}{Tab}{Tab}{Tab}{Down}{Tab}{Tab}{Enter}{Tab}"), True
For intA = 1 To 20
SendKeys ("+{Down}"), True
Next intA
SendKeys ("^(c)"), True
SendKeys "(%{F4})", True
AppActivate "Microsoft Access"
Me![Passwords].SetFocus
SendKeys ("^(v)"), True
SendKeys ("{Tab}")

End Sub
 
G

Guest

Cal No1 sets focus to the control Me![Password1], Cal No2 sets focus to the
control Me![Passwords]

Is 'Passwords' the name of a control?

Steve
 
S

SRT

They are both List Boxes, Me![Password1] accepts the request for focus,
however Me![Passwords] does not.


SteveM said:
Cal No1 sets focus to the control Me![Password1], Cal No2 sets focus to
the
control Me![Passwords]

Is 'Passwords' the name of a control?

Steve

SRT said:
Hi,

I have the following code below, which works if I do the following

Call No1
'Call No2
Exit Sub

For whatever reason it fails at Me![Passwords2].SetFocus at the end of
Sub
No2 with

Run-time Error '2110' - Unable to goto control

Any Ideas?

CODE:

Call No1
Call No2
Exit Sub

Sub No1()
strTest = Shell("C:\Program Files\MyApp\myapp.exe", 1)
sSleep (100)
AppActivate strTest
SendKeys ("12345"), True
SendKeys ("{Tab}{Enter}{Tab}"), True
For intA = 1 To 20
SendKeys ("+{Down}"), True
Next intA
SendKeys ("^(c)"), True
SendKeys "(%{F4})", True
AppActivate "Microsoft Access"
Me![Password1].SetFocus
SendKeys ("^(v)"), True
SendKeys ("{Tab}")

End Sub


Sub No2()
strTest = Shell("C:\Program Files\MyApp\myapp.exe", 1)
sSleep (100)
AppActivate strTest
SendKeys ("12345"), True
SendKeys ("{Tab}{Tab}{Tab}{Tab}{Down}{Tab}{Tab}{Enter}{Tab}"), True
For intA = 1 To 20
SendKeys ("+{Down}"), True
Next intA
SendKeys ("^(c)"), True
SendKeys "(%{F4})", True
AppActivate "Microsoft Access"
Me![Passwords].SetFocus
SendKeys ("^(v)"), True
SendKeys ("{Tab}")

End Sub
 
G

Guest

Hi

I think SteveM has given you the answer to this.

Check the name of the control and check how you've spelt it in your code.

For example:
In your first post you told us that the problem was with the control

Me![Passwords2]

but the controls in your code were

Me![Password1]

and Me![Passwords].SetFocus

Note the differences...
The first one is plural and has a number (ie 2)
The second one is singular and also has a number (ie 1)
The third is plural without a number!

hth

Andy Hull


SRT said:
They are both List Boxes, Me![Password1] accepts the request for focus,
however Me![Passwords] does not.


SteveM said:
Cal No1 sets focus to the control Me![Password1], Cal No2 sets focus to
the
control Me![Passwords]

Is 'Passwords' the name of a control?

Steve

SRT said:
Hi,

I have the following code below, which works if I do the following

Call No1
'Call No2
Exit Sub

For whatever reason it fails at Me![Passwords2].SetFocus at the end of
Sub
No2 with

Run-time Error '2110' - Unable to goto control

Any Ideas?

CODE:

Call No1
Call No2
Exit Sub

Sub No1()
strTest = Shell("C:\Program Files\MyApp\myapp.exe", 1)
sSleep (100)
AppActivate strTest
SendKeys ("12345"), True
SendKeys ("{Tab}{Enter}{Tab}"), True
For intA = 1 To 20
SendKeys ("+{Down}"), True
Next intA
SendKeys ("^(c)"), True
SendKeys "(%{F4})", True
AppActivate "Microsoft Access"
Me![Password1].SetFocus
SendKeys ("^(v)"), True
SendKeys ("{Tab}")

End Sub


Sub No2()
strTest = Shell("C:\Program Files\MyApp\myapp.exe", 1)
sSleep (100)
AppActivate strTest
SendKeys ("12345"), True
SendKeys ("{Tab}{Tab}{Tab}{Tab}{Down}{Tab}{Tab}{Enter}{Tab}"), True
For intA = 1 To 20
SendKeys ("+{Down}"), True
Next intA
SendKeys ("^(c)"), True
SendKeys "(%{F4})", True
AppActivate "Microsoft Access"
Me![Passwords].SetFocus
SendKeys ("^(v)"), True
SendKeys ("{Tab}")

End Sub
 

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