Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2006

Tip: Looking for answers? Try searching our database.

enumerating through certain controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DowningDevelopments - 31 Mar 2006 12:06 GMT
i wish to deposit certain values in certain controls, basically this is a
form where a refund value is to be split up into its indivudal numbers (which
ive already got) and converted to english (which ive already done) and then
deposited into certain boxes, so that units are stored in the me![units],
tens in me![tens], hundreds in me![hundreds] etc.
I was looking to make a loop that stripped off the last number of the refund
value and deposited into the next box.
i am trying to use an array of controls to store the sequence of the
controls that i will need and then use the loop to move through this array
too.

Ive got something like this
Dim box As Integer
Dim boxNames(units, tens, Ctl100s, Ctl1000s) As Control

box = 0

'while there are still numbers left in the value
Do While Numbersize > 0
       For box= 0 to boxname.length
      'find the value of the last number
               boxname(box) = ConvertDigit (Right(MyNumber))    
       'chop of that last number
          MyNumber = Mid(MyNumber, 0, Numbersize - 1)
       Next boxname
Loop

how do i form an array of controls as i need or this to work? it wont run
past that line of code!

with much appreciation for any help

Amit
Douglas J Steele - 31 Mar 2006 13:01 GMT
Access doesn't support control arrays. The closest you can get is to use a
naming convention for your controls (txt11, txt12, txt13, etc) and then
refer to the controls using Me.Controls("txt" & xvalue & yvalue)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> i wish to deposit certain values in certain controls, basically this is a
> form where a refund value is to be split up into its indivudal numbers (which
[quoted text clipped - 29 lines]
>
> Amit
DowningDevelopments - 31 Mar 2006 15:38 GMT
can i pass an array of strings which hold the names of the text boxes and
then construct the textboxes that i want to insert into?

Ive tried to do this below but its throwing up and error that im still
looking at. I know its a little stupid but i dont want to go aroudn changing
my textbox names as iv got other calculations in this module which would need
altering! but ill change it if all else fails

Dim NumberSize As Integer
Dim box As Integer
Dim boxNames(4) As String
Dim TextControl As String

NumberSize = Len(refund)
box = 0

boxNames(0) = "units"
boxNames(1) = "tens"
boxNames(2) = "hundreds"
boxNames(3) = "thousands"

'while there are still numbers left in the value
Do While NumberSize > 0
  'set the field to work with
  TextControl = boxNames(box)
  'find the value of the last number and put it into the field
  Me(TextControl) = ConvertDigit(Right(refund))
  'chop of that last number
  refund = Mid(refund, 0, NumberSize - 1)
  box 1
Loop

> Access doesn't support control arrays. The closest you can get is to use a
> naming convention for your controls (txt11, txt12, txt13, etc) and then
[quoted text clipped - 36 lines]
> >
> > Amit
Douglas J. Steele - 31 Mar 2006 23:26 GMT
Try using Me.Controls(TextControl) rather than Me(TextControl)

I suspect that you meant box = box + 1, rather than box 1

I also don't see anything in your code that changes the value of NumberSize,
meaning that you've got an infinite loop there.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> can i pass an array of strings which hold the names of the text boxes and
> then construct the textboxes that i want to insert into?
[quoted text clipped - 75 lines]
>> >
>> > Amit
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.