f



Shifting data to the right

Access97 using VBA code.
I have an array of textboxes, 8 columns across and 5 rows down.
If all the boxes in row 3 have data in them and I place my cursor in
the 4th box in this row, how can I move the contents of 4 to 5 then 5
to 6, 6 to 7, and 7 to 8.
I don't want to effect rows above and below row 3.
All I want to do is push data to the right making room to insert an
item to a lineup.
My textboxes are named txt01 thru txt40
Each row represents a different machine lineup.
I've looked at select case using Case txt17 to txt24 then breaking it
into if txt17 if txt18 etc. This looks bulky and I hoped there might
be a simpler solution via a function.
Any suggestions.

RICK
0
rbrowniii (85)
9/12/2003 2:41:51 AM
comp.databases.ms-access 42670 articles. 0 followers. Post Follow

2 Replies
395 Views

Similar Articles

[PageSpeed] 45

This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C378A7.A810CA10
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Rick--

With the naming system for the text boxes that you descibe, it sounds =
like there's no array or matrix of boxes, just a lot of single boxes.  =
You could take advantage of one of the ways to name a control, namely =
the
=20
Me("txt" & format(n,"00"))   =20

form, where n is the number of the box you want.  Using the setup you =
describe, you could use something like:

Sub MoveStuffRight(RowNum as Integer, ColNum as Integer)
'
'This just moves things right by one position.  Any contents in the last =
cell are lost.
'RowNum is the row you want to work in, and ColNum is the column of the =
box you=20
'will empty by moving its contents to the right
    For i =3D (ColNum * RowNum) + 1 to RowNum * 8
        Me("txt" & format(i, "00")) =3D me("txt" & format(i - 1, "00"))
    Next i
    Me("txt" & format(ColNum, "00")) =3D ""
    Me("txt" & format(ColNum, "00")).SetFocus  =20
End Sub

I haven't tried this out, of course.  Hope it helps. =20

Jim Beard


"Rick Brown" <rbrowniii@compuserve.com> wrote in message =
news:82227677.0309111841.7538be6c@posting.google.com...
> Access97 using VBA code.
> I have an array of textboxes, 8 columns across and 5 rows down.
> If all the boxes in row 3 have data in them and I place my cursor in
> the 4th box in this row, how can I move the contents of 4 to 5 then 5
> to 6, 6 to 7, and 7 to 8.
> I don't want to effect rows above and below row 3.
> All I want to do is push data to the right making room to insert an
> item to a lineup.
> My textboxes are named txt01 thru txt40
> Each row represents a different machine lineup.
> I've looked at select case using Case txt17 to txt24 then breaking it
> into if txt17 if txt18 etc. This looks bulky and I hoped there might
> be a simpler solution via a function.
> Any suggestions.
>=20
> RICK
------=_NextPart_000_000B_01C378A7.A810CA10
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1226" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT size=3D2>Rick--</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>With the naming system for the text boxes that you =
descibe, it=20
sounds like there's no array or matrix of boxes, just a lot of single=20
boxes.&nbsp; You could take advantage of one of the ways to name a =
control,=20
namely the</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;</FONT></DIV>
<DIV><FONT face=3D"courier new" size=3D2>Me("txt" &amp;=20
format(n,"00"))&nbsp;&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>form, where n is the number of the box you =
want.&nbsp; Using=20
the setup you describe, you could use something like:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Sub&nbsp;MoveStuffRight(RowNum =
as Integer,=20
ColNum as Integer)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>'</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>'This just moves things right =
by one=20
position.&nbsp; Any contents in the last cell are lost.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>'RowNum is the row you want to =
work in, and=20
ColNum is the column of the box you </FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>'will empty by moving its =
contents to the=20
right</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; For i =3D =
(ColNum *=20
RowNum)&nbsp;+ 1&nbsp;to RowNum * 8</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Me("txt" &amp; format(i, "00")) =3D me("txt" &amp; format(i - 1,=20
"00"))</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;Next =
i</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;Me("txt" &amp;=20
format(ColNum, "00")) =3D ""</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;Me("txt" &amp;=20
format(ColNum, "00")).SetFocus&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>End Sub</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I haven't tried this out, of course.&nbsp; Hope it=20
helps.&nbsp; </FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Jim Beard</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>"Rick Brown" &lt;</FONT><A=20
href=3D"mailto:rbrowniii@compuserve.com"><FONT=20
size=3D2>rbrowniii@compuserve.com</FONT></A><FONT size=3D2>&gt; wrote in =
message=20
</FONT><A =
href=3D"news:82227677.0309111841.7538be6c@posting.google.com"><FONT=20
size=3D2>news:82227677.0309111841.7538be6c@posting.google.com</FONT></A><=
FONT=20
size=3D2>...</FONT></DIV><FONT size=3D2>&gt; Access97 using VBA =
code.<BR>&gt; I have=20
an array of textboxes, 8 columns across and 5 rows down.<BR>&gt; If all =
the=20
boxes in row 3 have data in them and I place my cursor in<BR>&gt; the =
4th box in=20
this row, how can I move the contents of 4 to 5 then 5<BR>&gt; to 6, 6 =
to 7, and=20
7 to 8.<BR>&gt; I don't want to effect rows above and below row =
3.<BR>&gt; All I=20
want to do is push data to the right making room to insert an<BR>&gt; =
item to a=20
lineup.<BR>&gt; My textboxes are named txt01 thru txt40<BR>&gt; Each row =

represents a different machine lineup.<BR>&gt; I've looked at select =
case using=20
Case txt17 to txt24 then breaking it<BR>&gt; into if txt17 if txt18 etc. =
This=20
looks bulky and I hoped there might<BR>&gt; be a simpler solution via a=20
function.<BR>&gt; Any suggestions.<BR>&gt; <BR>&gt; =
RICK</FONT></BODY></HTML>

------=_NextPart_000_000B_01C378A7.A810CA10--

0
9/12/2003 4:00:07 AM
Thanks for your reply, it didn't work out of the box but after a
little tweaking I got it to work.  This will save loads of coding and
re-naming of my textboxes. It got my mind looking at it differently as
I was bogged down.
Thanks for taking the time.
Rick


"Jim Beard" <james.beard@comcast.net> wrote in message news:<bxb8b.420166$o%2.191156@sccrnsc02>...
> Rick--
> 
> With the naming system for the text boxes that you descibe, it sounds 
> like there's no array or matrix of boxes, just a lot of single boxes.  
> You could take advantage of one of the ways to name a control, namely 
> the
>  
> Me("txt" & format(n,"00"))    
> 
> form, where n is the number of the box you want.  Using the setup you 
> describe, you could use something like:
> 
> Sub MoveStuffRight(RowNum as Integer, ColNum as Integer)
> '
> 'This just moves things right by one position.  Any contents in the last 
> cell are lost.
> 'RowNum is the row you want to work in, and ColNum is the column of the 
> box you 
> 'will empty by moving its contents to the right
>     For i = (ColNum * RowNum) + 1 to RowNum * 8
>         Me("txt" & format(i, "00")) = me("txt" & format(i - 1, "00"))
>     Next i
>     Me("txt" & format(ColNum, "00")) = ""
>     Me("txt" & format(ColNum, "00")).SetFocus   
> End Sub
> 
> I haven't tried this out, of course.  Hope it helps.  
> 
> Jim Beard
> 
> 
> "Rick Brown" <rbrowniii@compuserve.com> wrote in message 
> news:82227677.0309111841.7538be6c@posting.google.com...
> > Access97 using VBA code.
> > I have an array of textboxes, 8 columns across and 5 rows down.
> > If all the boxes in row 3 have data in them and I place my cursor in
> > the 4th box in this row, how can I move the contents of 4 to 5 then 5
> > to 6, 6 to 7, and 7 to 8.
> > I don't want to effect rows above and below row 3.
> > All I want to do is push data to the right making room to insert an
> > item to a lineup.
> > My textboxes are named txt01 thru txt40
> > Each row represents a different machine lineup.
> > I've looked at select case using Case txt17 to txt24 then breaking it
> > into if txt17 if txt18 etc. This looks bulky and I hoped there might
> > be a simpler solution via a function.
> > Any suggestions.
> > 
> > RICK
>  --
0
rbrowniii (85)
9/12/2003 5:24:08 PM
Reply: