K
kev100 via AccessMonster.com
I'm just beginning to how to use earn VBA programming with Access. Up to
this point....I've gotten by with creating Access queries, macors, etc.
I'm needing to simply have a popup box that accepts user input (e.g. Input
First Name save it to a variable...and then be able to reference that
variable in other forms, queries, etc. The information will generally NOT
need to be permantely saved. When the app is exited...it's okay if it goes
away.
I'm assuming that there is no "User Input Popup Wizard" in Access...so
creating code to do this is the only option.
The following code was suggested in another forum...
Option Compare Database
Public gbl_UserInput As String
Option Explicit
Dim strInput As String
Dim strMsg As String
strMsg = "Input First Name:"
strInput = InputBox(Prompt:=strMsg, title:="First Name")
gbl_UserInput = strInput
To test, I create a form with 1 button. Then select the button's properties
and then Event/On Click / ... and enter the above code.
On running the form and entering clicking the button....the error occurs:
Compile Error
Invalid Inside Procedure
....and the "Option Compare Database" line is highlighted.
I've tried a little guess-editing here and there...but simply can't get it to
run. I can't help thinking it must be some simple issue as this has to be a
really common function.
Thanks
this point....I've gotten by with creating Access queries, macors, etc.
I'm needing to simply have a popup box that accepts user input (e.g. Input
First Name save it to a variable...and then be able to reference that
variable in other forms, queries, etc. The information will generally NOT
need to be permantely saved. When the app is exited...it's okay if it goes
away.
I'm assuming that there is no "User Input Popup Wizard" in Access...so
creating code to do this is the only option.
The following code was suggested in another forum...
Option Compare Database
Public gbl_UserInput As String
Option Explicit
Dim strInput As String
Dim strMsg As String
strMsg = "Input First Name:"
strInput = InputBox(Prompt:=strMsg, title:="First Name")
gbl_UserInput = strInput
To test, I create a form with 1 button. Then select the button's properties
and then Event/On Click / ... and enter the above code.
On running the form and entering clicking the button....the error occurs:
Compile Error
Invalid Inside Procedure
....and the "Option Compare Database" line is highlighted.
I've tried a little guess-editing here and there...but simply can't get it to
run. I can't help thinking it must be some simple issue as this has to be a
really common function.
Thanks