I have a form and a module for this example. Form is frmAlarms , module is modAlarms
I can call a Case number from module to fire on timer event for the form.
If I hard code it, no problem, it works.
SelectCase CommandNumber
Case is = 2
Case MsgBox = Forms!frmAlarms!txtFunctionName.Value ' Will this work?
I want to be able to enter whatever I want for Case 2, as a message and then have the timer event use it.
txtFunctionName is the textbox for the Case statement value on frmAlarms
Call Value in module
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Call Value in module
Do you want the user to enter a value or do you want to use the value of txtFunctionName?
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Call Value in module
This is my dilemma, I can use the module and call a command to be executed, like DoCmd.Beep
And If I hard code the Case statement it works as well.
What I'm trying to figure out is if the user enters a message in txtFunction that is not hard coded in the function will it work?
Not sure if it's possible to do both or not.
And If I hard code the Case statement it works as well.
What I'm trying to figure out is if the user enters a message in txtFunction that is not hard coded in the function will it work?
Not sure if it's possible to do both or not.
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Call Value in module
Again,unsure of my approach or syntax but here goes.
If IsNull Case.CommandNumber Then
Me.txtFunctionName = MsgBox & "'" & Me.txtFunctionName
End If
If IsNull Case.CommandNumber Then
Me.txtFunctionName = MsgBox & "'" & Me.txtFunctionName
End If
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Call Value in module
That won't work, but I still do not understand what you are trying to do...
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Call Value in module
Any value I use in the field txtFunctionName will work if its hard coded in the module.
If its not in the module then what are my options?
I can write in txtFunctionName Hi there and when the time event fires, the message will show up.
If the functionname is not in the module of course nothing will happen.
This db is for timed events to happen at whatever time is selected. Ex; Let me know when its time for lunch or make a beep sound at 5pm
This all works because they would be in the module hard coded.
If they are not is my question, how can I make it work?
If its not in the module then what are my options?
I can write in txtFunctionName Hi there and when the time event fires, the message will show up.
If the functionname is not in the module of course nothing will happen.
This db is for timed events to happen at whatever time is selected. Ex; Let me know when its time for lunch or make a beep sound at 5pm
This all works because they would be in the module hard coded.
If they are not is my question, how can I make it work?
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Call Value in module
Case is = 2
MsgBox = "Hi there"
rs!FuncationName = Me.txtFunctionName
Q is, Can I leave the MsgBox Null and populate it from the value in txtFuncationName ?
MsgBox = "Hi there"
rs!FuncationName = Me.txtFunctionName
Q is, Can I leave the MsgBox Null and populate it from the value in txtFuncationName ?
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Call Value in module
Hans, sorry for my poor communication skills. I think I now have the answer. Leave the hard coded variables in the module and if the variable does not exists then it will treat it as text.
I will play around with it a bit and post back later.
I will play around with it a bit and post back later.
-
- PlutoniumLounger
- Posts: 15647
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Call Value in module
Hi burrina ; this is probably not the place for a philosophical discussion on programming techniques, but if it were I would make the case that there should be no hard-coded variables in procedure code.
I can make a case for hard-coded labelled constants in procedure code: "Public Const lngcMonthsInYear as Long = 12" and then making use of the identifier "lngcMonthsInYear " within a procedure, but a value such as (example) The Number Of Branch Offices ought always be stored at run-time in a named variable.
I frequently make use of literal numeric values in procedure code while I am "getting it to work", but I [should] always replace the literal numeric value (12) with the symbolic value (lngcMonthsInYear) before I release the code.
Again, right now you need/want to get your code working, so we should not discuss this here. I mention it because I have caused myself so many problems in the past by leaving hard-coded variables in procedure code. They come back and bite me months or years after the code is released!
Cheers
Chris
He who plants a seed, plants life.
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Call Value in module
Thanks for the advice. It was hard enough getting the code to work in the 1st place.
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Call Value in module
Oh, FYI The code works perfectly, its just the user friendly setup that is the problem.
Thanks so much.
Thanks so much.
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Call Value in module
Hans, in all fairness to you it was my lack of communicating that was the issue. I have since solved the problem.
I apologize for my unclear post.
Thanks,
I apologize for my unclear post.
Thanks,
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands