Why doesn't this work in Access?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This errors on the varTemp = Eval(Mid(ctl.OnClick, 2))
line. And while the OnClick property shows in the Object Browser, it does
not appear in the property/method list when you type "ctl.".


Public Function DoIt()
Dim ctl As Control, varTemp As Variant

Set ctl = Forms!tester!cmdOne
If (Left(ctl.OnClick, 1) = "=") Then
varTemp = Eval(Mid(ctl.OnClick, 2))
Else
MsgBox "didn't work"
End If

End Function
 
Perico said:
This errors on the varTemp = Eval(Mid(ctl.OnClick, 2))
line. And while the OnClick property shows in the Object Browser, it
does not appear in the property/method list when you type "ctl.".


Public Function DoIt()
Dim ctl As Control, varTemp As Variant

Set ctl = Forms!tester!cmdOne
If (Left(ctl.OnClick, 1) = "=") Then
varTemp = Eval(Mid(ctl.OnClick, 2))
Else
MsgBox "didn't work"
End If

End Function

What error does it give you? I just tried something like that, and it
worked. What is in the OnClick property of cmdOne? Is the form
"tester" open when you call DoIt? I don't think all Access controls
have an OnClick property, so that's why the OnClick property doesn't
appear in the intellisense list for ctl. That doesn't mean you can't
call it, though, so long as the property does exist for the particular
instance of Control that you call it for.
 
It works fine for me.

What error are you running into?

You do know that the tester form must be open before you can use that code.

BTW, the reason OnClick doesn't show up in the intellisense is because
Control is a generic object. Not all controls have a Click event associated
with them. If you were to use Dim ctl As CommandButton, you should see it in
the list.
 
I am getting an"out of stack space error.




Dirk Goldgar said:
What error does it give you? I just tried something like that, and it
worked. What is in the OnClick property of cmdOne? Is the form
"tester" open when you call DoIt? I don't think all Access controls
have an OnClick property, so that's why the OnClick property doesn't
appear in the intellisense list for ctl. That doesn't mean you can't
call it, though, so long as the property does exist for the particular
instance of Control that you call it for.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Getting an out of stack space error.

Douglas J. Steele said:
It works fine for me.

What error are you running into?

You do know that the tester form must be open before you can use that code.

BTW, the reason OnClick doesn't show up in the intellisense is because
Control is a generic object. Not all controls have a Click event associated
with them. If you were to use Dim ctl As CommandButton, you should see it in
the list.
 
got it to work; thanks

Dirk Goldgar said:
What error does it give you? I just tried something like that, and it
worked. What is in the OnClick property of cmdOne? Is the form
"tester" open when you call DoIt? I don't think all Access controls
have an OnClick property, so that's why the OnClick property doesn't
appear in the intellisense list for ctl. That doesn't mean you can't
call it, though, so long as the property does exist for the particular
instance of Control that you call it for.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
now works; thank you

Douglas J. Steele said:
It works fine for me.

What error are you running into?

You do know that the tester form must be open before you can use that code.

BTW, the reason OnClick doesn't show up in the intellisense is because
Control is a generic object. Not all controls have a Click event associated
with them. If you were to use Dim ctl As CommandButton, you should see it in
the list.
 
Back
Top