Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 13th, 2006, 12:50 AM
Registered User
 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to make a global variable?

Hi all!
I have a simple access form. It as a command button. When I click the command button on the form, the first form closes(dcmd.close), another form opens(docmd.open) which again has a command button. When I again click the command button of this form, the form closes and a new form opens. There are 30 forms in total, with 1 command button in each form. What I need is at the every click of command button a integer variable should have increment +1 so that at the end I can cout the total no. of forms or command button.
 
Old February 14th, 2006, 08:45 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Create a module with a Public variable declaration, and then refer to that variable with each button On Click:

'---
'Module
Dim Public myVariable As Integer

'myVariable = ? default is 0
'---
'On Click
myVariable = myVariable + 1

HTH


mmcdonal
 
Old February 14th, 2006, 08:46 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I think the syntax is "Public myVariable As Integer," not "Dim Public"

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
comapring global variable value to local variable amhicraig XSLT 6 December 5th, 2007 12:16 PM
Global Variable techfreak123 XSLT 0 August 3rd, 2006 07:45 AM
global variable? milk_vanilla Classic ASP Basics 3 January 8th, 2005 06:50 PM
global variable in c# kobystud C# 3 April 22nd, 2004 05:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.