Mark Rock
Registered User.
- Local time
- Today, 12:32
- Joined
- Jan 5, 2007
- Messages
- 16
I have read and re-read so many posts on using globals. Apparently, I am more lost then I thought-- they refuse to work for my application as coded.
Access VBA Module: mod_global_defs,
Access VBA Module: Test4_Full,
I run the program. Click on the button and immediately receive, "Run-time error '91': Object variable or With block variable not set"
When I click debug it points to the MsgBox(mycntl) line. I right clicked mycntl and it correctly knows that the global was defined in mod_global_defs. I tried several other usages for mycntl within myMouseDown and it fails each time regardless whenever I try to read from mycntl, including such as noted in that function's comments, mycntl.Caption = "something". Therefore, I am guessing it has a blank definition on the control (I checked the Debug's Watch and it doesn't seem to have what I would expect).
Any HELP Appreciated.
Access VBA Module: mod_global_defs,
Code:
Option Compare Database
Option Explicit
Public myfrm As New Form
Public mycmdbutton As Control
Access VBA Module: Test4_Full,
Code:
Public Function myMouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim mycntl As Control
Set mycntl = GetCmdButtonVar()
MsgBox (mycntl.Caption) 'Fails here. Also fails here even if I have something like mycntl.Caption = "some words"
End Function
Public Function GetCmdButtonVar() As Control
Set GetCmdButtonVar = mycmdbutton
End Function
Public Function CascadeAllNoisesToAllDVMs() As Boolean
On Error Resume Next
Set myfrm = CreateForm(, "Form_Template")
Set mycmdbutton = CreateControl(myfrm.Name, acCommandButton, acDetail, "", "", 7250, 1250, 2000, 500)
mycmdbutton.Name = "myButton"
mycmdbutton.OnMouseDown = "=myMouseDown(0, 0, 0, 0)"
DoCmd.OpenForm myfrm.Name, acNormal
End Function
I run the program. Click on the button and immediately receive, "Run-time error '91': Object variable or With block variable not set"
When I click debug it points to the MsgBox(mycntl) line. I right clicked mycntl and it correctly knows that the global was defined in mod_global_defs. I tried several other usages for mycntl within myMouseDown and it fails each time regardless whenever I try to read from mycntl, including such as noted in that function's comments, mycntl.Caption = "something". Therefore, I am guessing it has a blank definition on the control (I checked the Debug's Watch and it doesn't seem to have what I would expect).
Any HELP Appreciated.
Last edited: