Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2006

Tip: Looking for answers? Try searching our database.

SAVING Basic User Input (for use elsewhere)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kev100 - 15 Apr 2006 20:57 GMT
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
John Vinson - 15 Apr 2006 23:08 GMT
>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.

Rather than using an inputbox and a variable, I'd suggest simply using
a Form with textboxes (or combo boxes or other controls) into which
the user can enter or select the desired values.

Other Forms, Queries, and Reports can reference

=Forms![NameOfTheForm]![NameOfTheControl]

so long as the form stays open.

                 John W. Vinson[MVP]    
kev100 - 16 Apr 2006 02:02 GMT
COOL !....that looks like it's working....and leading to some other very
handy functions as well.  Thanks!

What I've done is to create a form which has a text box into which the user
enters data.

I have an existing form created based on a query.  The query references the
data entered in that text box to perform a calculation.  

I placed a button on this new  form (with the text entry box) that will open
that existing form when clicked.....so...the user can open this new form,
make an entry, click the button....and the other form pops ups with the info
and updated calculations based on what they just entered.

I noticed that you can embed a form into a form (called subforms?)....so that
when the form is opened.....the other embedded form is displayed as well....
very cool.

HOWEVER.....when I do this....and the user clicks the button after entering
data into into the box...the form that is embedded pops up in a window (with
the update results).  The data on the embedded instance of that form does not
change.

It would be great if only the embedded form were visable when clicking that
button.....and if different data were entered in text box above....clicking
the button would update the values in the embedded view of the existing form
(sort of refreshing it...since that form is based on a query that references
the data entered)

Is anything like this possible?

Thanks very much.
John Vinson - 16 Apr 2006 06:16 GMT
>It would be great if only the embedded form were visable when clicking that
>button.....and if different data were entered in text box above....clicking
>the button would update the values in the embedded view of the existing form
>(sort of refreshing it...since that form is based on a query that references
>the data entered)

It's even simpler than that.

You don't need the button, or even any VBA code AT ALL!

Simply make the user's textbox the Master Link Field of the subform,
and the corresponding field in the table upon which the subform is
based the Child Link Field. The Subform's recordsource should contain
all the records which might match.

                 John W. Vinson[MVP]    
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.