Iterate through Field names

G

Guest

Thanks for taking the time to read my question.

I have 5 fields named UpdatedTo with a number at the end
i.e. UpdatedTo1, UpdatedTo2, UpdatedTo3, UpdatedTo4, UpdatedTo5.

in my With statement, how can I iterate through these names with a variable?

i.e !UpdatedTo & x

This is what I have in my code but it doesn't work.

I want to do the same thing here as I am doing with the Controls() function.

Thanks so much for your help.

Brad

==================================================
Code:



Do Until x = 6
If Not IsNull(Me.Controls("SplitANumber" & x)) And
Me.Controls("SplitANumber" & x) <> 0 Then
With rst
.AddNew ' Add new record.
!FirstName = Me.SplitFirstName ' Add data.
!LastName = Me.SplitLastName ' Add data.
!PhoneNumber = Me.SplitPhoneNumber ' Add data.
!Gender = Me.SplitGender ' Add data.
!ANumber = Me.Controls("SplitANumber" & x) '
Add data.

'Line With Problem
!UpdatedTo & x = a + x ' Add data.


.Update ' Save changes.
End With

x = x + 1

Else
x = x + 1
End If
Loop
==================================================
 
B

Brendan Reynolds

..Fields("UpdatedTo" & x)

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
A

Andi Mayer

On Wed, 12 Jan 2005 08:25:03 -0800, "Brad"

see inline
Do Until x = 6
If Not IsNull(Me.Controls("SplitANumber" & x)) And
Me.Controls("SplitANumber" & x) <> 0 Then
With rst
.AddNew ' Add new record.
!FirstName = Me.SplitFirstName ' Add data.
!LastName = Me.SplitLastName ' Add data.
!PhoneNumber = Me.SplitPhoneNumber ' Add data.
!Gender = Me.SplitGender ' Add data.
!ANumber = Me.Controls("SplitANumber" & x) '
Add data.

'Line With Problem
!UpdatedTo & x = a + x ' Add data.

.fields("UpdatedTo" &x)=a+x
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top