Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 June 18th, 2003, 01:20 PM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to reference Public Variable in Code

I know I can direct use Public Variable in code, but sometime I wish to use variable to reference it. Such as:

**Define Public Variable in Module

Public strA1 as string
Public strA2 as string
....
Public strA10 as string

***In Form VBA code, I wish can use For..Next loop command to reference Public variable, such as:

For i = 1 to 10
   strAAA = strAAA & PublicVariable("strA" & i) <--- Sorry, I don't know how to do it in code..
Next i


:)Do anyone can help me? Thanks a lot...





Best Regards,
Gino Liu at CI.
 
Old June 18th, 2003, 01:40 PM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use an Array instead

Public strA(10)as string

***In Form VBA code, I wish can use For..Next loop command to reference Public variable, such as:

For i = 1 to 10
     strAAA = strAAA & strA(1)
Next i
 
Old June 18th, 2003, 01:42 PM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Error in code updated.

Use an Array instead

Public strA(10)as string

***In Form VBA code, I wish can use For..Next loop command to reference Public variable, such as:

For i = 1 to 10
strAAA = strAAA & strA(1) <=== i not 1 here.
Next i





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use a run time variable as public Subuana Beginning VB 6 2 May 1st, 2006 03:27 PM
Passing Public Variables in Code-Behind striker9 ASP.NET 2.0 Basics 7 February 11th, 2006 03:54 PM
Can an object reference be public? maxpotters Excel VBA 2 March 6th, 2005 01:22 PM
difference b/w shared and public variable lgeetha VS.NET 2002/2003 1 March 4th, 2005 08:24 AM
Passing variable to a public variable Hudson40 Access VBA 2 February 25th, 2005 06:23 AM





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