Re: Loop through names of controls
From: MikeB (m.byerleyATVerizonDottieNettie)
Date: 10/17/04
- Next message: Paul James: "Thanks to Ken and Marsh"
- Previous message: John Vinson: "Re: updateability of linked tables"
- In reply to: Dan Artuso: "Re: Loop through names of controls"
- Next in thread: Dan Artuso: "Re: Loop through names of controls"
- Reply: Dan Artuso: "Re: Loop through names of controls"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 17 Oct 2004 15:47:36 -0500
oops. Looked too quick. Didn't scroll down to the string of the sql. I
thought he was having trouble getting an object in his loop.
"Dan Artuso" <dartuso@NSpagepearls.com> wrote in message
news:ubBJhjItEHA.2072@tk2msftngp13.phx.gbl...
> Hi,
> This is how you would refer to a control in your loop:
> stEstCode = Me("cboEstCode" & intEstCode)
>
> AND
>
> stCands = Me("txtCands" & intCands)
>
>
>
> --
> HTH
> Dan Artuso, Access MVP
>
>
> "Baby Face Lee" <BabyFaceLee@discussions.microsoft.com> wrote in message
news:BB6D7288-FB04-4D9F-9A6A-709AA548E95F@microsoft.com...
> > Hello (again)
> > Sorry to keep bothering you guys but I'm having probs trying to do a loop.
> > I've got a control (well two infact) that each have the same name except for
> > a number at the end (eg cboEstCode1 to cboEstCode12) - there are 12 of them.
> > I'm running some SQL to insert the value in each control into a table. I
> > thought I'd do a For/Next loop that goes round 12 times adding the digit to
> > the end of the control name but the SQL is taking the string values
literally
> > (not surprisingly) rather than finding the value that's in the name of the
> > control.
> > Here's my code:
> >
> > Set db = DBEngine(0)(0)
> >
> > For intEstCode = 1 To 12
> > stEstCode = "cboEstCode" & intEstCode
> > For intCands = 1 To 12
> > stCands = "txtCands" & intCands
> >
> > strSQL = "INSERT INTO tbl_Estimates (CentreNo, EstCode, Cands)" _
> > & " VALUES (" & Me!cboCentreNo & ", " & "'" & stEstCode & "'" & ", "
> > & stCands & ");"
> > db.Execute strSQL
> > Exit For
> > Next
> > Next
> >
> > I know this is not the way a form should be constructed but I'm trying to
> > 'push' the data into a table to improve speed and a continuous form doesn't
> > work because being Unbound it doesn't hold more than one record at a time.
> > Sorry for all the waffle but can you help with this? Have I got the loop
> > structure right too?
> > Thanks guys!
> > Lee
>
>
- Next message: Paul James: "Thanks to Ken and Marsh"
- Previous message: John Vinson: "Re: updateability of linked tables"
- In reply to: Dan Artuso: "Re: Loop through names of controls"
- Next in thread: Dan Artuso: "Re: Loop through names of controls"
- Reply: Dan Artuso: "Re: Loop through names of controls"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|