By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,139 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,139 IT Pros & Developers. It's quick & easy.

Shifting data to the right

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <rb*******@compuserve.com> wrote in message news:82**************************@posting.google.c om...
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

Nov 12 '05 #2

P: n/a
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" <ja*********@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" <rb*******@compuserve.com> wrote in message
news:82**************************@posting.google.c om...
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

--

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.