Variable Lifespan

JReichnan

Registered User.
Local time
Today, 11:33
Joined
Oct 28, 2005
Messages
33
Hello,

I have a switchboard with 3 buttons. Each button calls up a different report. Each report uses a similar form so that the user can input starting date and ending date via a calendar. Once the dates are established an OK button is pressed to call up the appropriate report. Since the date form is the same in all three cases is there a way that by pushing the report button the object name can be carried via a variable to the VBA code in a single date form so that when the OK button is pushed the appropriate report will come up. Thanks, Jeff!
 
You should be able to do this with the OpenArgs attribute...

Here is a link that may help: Link
 
Put the variable in a separate module and declare it as public. If you want, you could make it a function, so you could retrieve and/or store it whenever you call it.
 
Banana said:
Put the variable in a separate module and declare it as public. If you want, you could make it a function, so you could retrieve and/or store it whenever you call it.

Would this cause issues in a multi-user setup?
 
You may be right; I didn't realize he needed it for multiple users environment.
 
This is for a number of single user installations in remote locations. Eventually just the date will be uploaded to a SQL server, possible
 
Thanks all...this will not be a multi user environemnt. It will be single user with an upload to a SQL server for just the data on a later date.
 
Last edited:
Thanks Banana, I think you are on the right track with the Public pathway. Just so you know. When I press the button on the switchboard... at that point the name of the report is identified as EvalByAllPoints. If I were to hit another button on the switchboard the report would be "Summary". The code would all be the same but the variable would be different.

Private Sub AllCaddieReport_Click()
Dim strSQL As String
Dim strDocName As String
Dim frmDocName As String
Dim strCtrlName As String
Dim strRepName As String

DoCmd.SetWarnings False

strSQL = "Delete StartDate.*, EndDate.* From DateRange;"
DoCmd.RunSQL strSQL

strDocName = "DateRange"
frmDocName = "Switchboard"
strCtrlName = "StartDate"
strRepName = "EvalByAllPoints"
Forms!Switchboard.Visible = False
DoCmd.OpenForm strDocName
DoCmd.GoToControl strCtrlName
End Sub

So you see it then passes off to the Date Range Form which in turn will open the report EvalByAllPoints. However in that code the obect variable is set back to none so to speak. So, how using a Public situation can I say, whichever button on the switchboard I hit, Keep that variable for the next VBA procedure. Thanks.
 
You would basically copy the code and insert it into its own module, with the header Public Function YourName(Byval whatevervariableyouneed As whatever), then in the button click event, use Call YourName(whatevervariableyouneed).
 

Users who are viewing this thread

Back
Top Bottom