Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I signed up to your site to get help with a problem and I am so glad I did. I found the help I needed immediately. Thanks to all who contribute to your site..."

Geography

Where in the world do Tek-Tips members come from?

Populate fields in excel from access form

access101 (Programmer)
27 May 12 11:10
i have a form with 60 textboxes named I1- I60

i need a for statement that will loop through and populate my excel spreadsheet
for this example
I1=54.25
I2=38.16
so far i have this which works but is not looping correctly
For a = 7 To 8
For b = 1 To 2
xlSheet.Range("d" & a) = Me("I" & b)
Next b, a

once i run the code

excel shows
d7 = 38.16
d8 = 38.16
dhookom (Programmer)
28 May 12 15:56
Your code is expecting to find a bound control name "I1" and "I2". You might want to use arrays or possibly the Eval() function.

Duane
Hook'D on Access
MS Access MVP

access101 (Programmer)
28 May 12 16:49
can you please show me an example
dhookom (Programmer)
28 May 12 22:17
It would help to understand you requirements better. However consider code like:

CODE --> vba

Public Function TestArray() Dim arI(2) Dim b As Integer arI(1) = 54.25 arI(2) = 38.16 For b = 1 To 2 Debug.Print arI(b) Next End Function

Duane
Hook'D on Access
MS Access MVP

TheAceMan1 (Programmer)
29 May 12 7:57
access101 . . .

Just a guess ...

CODE

Dim a As Long, b As Long For a = 7 To 8 b = a - 6 xlSheet.Range("d" & a) = Me("I" & b) Next

See Ya! . . . . . .

Be sure to see FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions? Worthy Reading! thumbsup2
Also FAQ181-2886: How can I maximize my chances of getting an answer? Worthy Reading! thumbsup2

access101 (Programmer)
29 May 12 22:28
thanks TheAceMan1 that worked! I still don't understand why your code worked vs mine but appreciate the help.
TheAceMan1 (Programmer)
30 May 12 7:08
access101 . . .

Hint! ... you only need one loop!

See Ya! . . . . . .

Be sure to see FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions? Worthy Reading! thumbsup2
Also FAQ181-2886: How can I maximize my chances of getting an answer? Worthy Reading! thumbsup2

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close