Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 30th, 2006, 02:13 PM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using a var into the name of another var or field.

Ok, here is what I am trying to do:

Dim i As Byte
For i = 1 To 7
    Set Rst = CurrentDb.OpenRecordset("SELECT * from tbl_Divisao WHERE CodigoDivisao =" & i & "and Pago = 0")
    While Not Rst.EOF
      sum&i = sum&i + Rst!Valor
      Rst.MoveNext
    Wend
Me.total&i = sum&i
Next

These &i are just for the example, they dont work. I want to know how to make them work =) I mean, I want in each FOR to create sum1 to sum7 and use them in Me.Total1 to Me.Total7

hope I made myself clear....

Reply With Quote
  #2 (permalink)  
Old May 30th, 2006, 02:20 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

A good way to do this would be to use an array

Dim sum(7) as double
for i = 1 to 7
  ...
  sum(i) = sum(i) + Rst!Valor
  ...
Me.Form.Controls("total" & i) = sum(i)
Next


Mike
EchoVue.com
Reply With Quote
  #3 (permalink)  
Old May 30th, 2006, 02:31 PM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much.. it worked =)

Reply With Quote
  #4 (permalink)  
Old May 30th, 2006, 03:47 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Good to hear! It's always a relief when it actually works.

Welcome to the forum - I haven't found a better resource for VBA yet!

Mike

Mike
EchoVue.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
var,text ,..... angelboy SQL Language 2 May 29th, 2007 11:37 AM
"Out of scope" var??? yankleber XSLT 2 March 31st, 2007 03:53 AM
var as variable incredi-man Javascript 2 September 16th, 2006 11:46 AM
Dissapearing VAR topshed Classic ASP Databases 5 June 3rd, 2005 01:34 PM
Temp Var in For Each pbernardo XSLT 5 November 14th, 2003 06:45 PM



All times are GMT -4. The time now is 04:23 PM.


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