Microsoft Access - Label Printing - each 10 labels to print vertically - label

Good day, I am having an issue, I need to print 3000 lables every 7 days and they are cut in to individual lables, at the moment they are printing in sequence 1,2,3,4,5,6...etc, so person wastes time to pick them up and put them in correct slots
Now what I need is that record Number 2 is printed on 2nd page, 3rd record on page 3 and like this 10 pages, my 11 record under is on 1st page just below record number 1, record 12 is on page 2 under record number 2.....
So idea is that person can grab a stack of 10 record instead of taking them one by one, but I am not sure how can I do it=\ any Ideas?

' Macro to assign numbers to data source so that it can be sorted to cause labels to print down columns
Dim Message, Title, Default, labelrows, labelcolumns,
i As Integer, j As Integer,
k As Integer
Message = "Enter the number of labels in a row" ' Set prompt.
Title = "Labels per Row" ' Set title.
Default = "3" ' Set default.
' Display message, title, and default value.
labelcolumns = InputBox(Message, Title, Default)
Message = "Enter the number of labels in a column" ' Set prompt.
Title = "Labels per column" ' Set title.
Default = "5" ' Set default.
labelrows = InputBox(Message, Title, Default)
ActiveDocument.Tables(1).Columns.Add
BeforeColumn:=ActiveDocument.Tables(1).Columns(1)
ActiveDocument.Tables(1).Rows(1).Range.Cut
k = 1
For i = 1 To ActiveDocument.Tables(1).Rows.Count - labelcolumns
For j = 1 To labelrows
ActiveDocument.Tables(1).Cell(i, 1).Range.InsertBefore k + (j - 1) *
labelcolumns
i = i + 1
Next j
k = k + 1
i = i - 1
If k Mod labelcolumns = 1 Then k = k - labelcolumns + labelcolumns *
labelrows
Next i
ActiveDocument.Tables(1).Sort FieldNumber:="Column 1"
ActiveDocument.Tables(1).Rows(1).Select
Selection.Paste
ActiveDocument.Tables(1).Columns(1).Delete
this one I had was for word, unfortunately it didn't work exactly the way I need

Related

Display tables between two numbers

I have been trying to create a VB script using the "Do While" loop in the VBScript. I want to generate tables between two numbers accepted from the user I don't know what's wrong with this:
option explicit
Dim i, a, j, product, table
a = inputbox("enter a number")
For i=1 to a
j=1
Do while(j<=10)
product=i*j
a=i&"*"&j&"="&product
table=table&vbnewline&a
loop
msgbox table
next
The above results in a blank window.
Can anyone help me resolve the problem?
P.S.
I managed to get it to work using the "For" loop.
Option 1: Use a For loop:
Dim i
For i = 1 To 10
' This will run 10 times
Next
Option 2: Use a Do While loop:
Dim j
j = 1
Do While j <= 10
' This will also run 10 times
j = j + 1
Loop
Edit:
If you need to loop on both i and j, you can create a nested For loop:
Dim i, j
For i = 1 To 10
For j = 1 To 10
' This will run 10 times for each value of i (so 100 total)
Next
Next

Generate first 10 numbers of a sequence

I have been trying to create this sequence:
2,7,17,37,67,...
I have to print first 10 numbers of the series.
To do this, I have created the following:
option explicit
Dim m,n,i,str,d
m=2
d=10
n=7
For i=0 to 10
n=n+d
d=d+10
str=str&n&vbcrlf
msgbox str
next
I am unable to print first two numbers, 2 and 7, as they are declared before the for loop. Even if I store them in a variable called str, they get printed after every execution. Is there a way to add these two and print them only once.
You could add your initial value of m to your string before you start running your sequence. Then, append the value of n to your string at the start of your loop instead of the end so that you capture n's initial value. For example:
m=2: d=10: n=7
str = m & vbCrLf ' Capture initial value of m
For i = 1 to 9
str = str & n & vbCrLf ' Capture initial value of n
n = n + d
d = d + 10
Next
MsgBox str
Note that you're only looping 9 times now, since you've already captured the first number in your sequence (m) prior to your loop.
I also moved MsgBox outside your loop so that it only appears once, after the full 10-number sequence has been generated.

How to check if an item is already in a listbox in vb6

I'm working with vb6 and I want to generate multiple randum numbers (the range from to is detirmend by user and also the number of generated answers) and send them to a listbox
But I don't want to duplicate generated numbers So..
I want before sending the generated number to the listbox to check if it already exists in the lisbox. if it already exists then generate another number if it does't then send it the the listbox
here is what I have till now
max and min are the range to chose numbers between
answers is the number of generated numbers
Randomize
For i = 1 To answers Step 1
generated = CInt(Int((max - min + 1) * Rnd() + min))
For n = 0 To List1.ListCount
If List1.List(n) <> gen Then
List1.AddItem (gen)
Else
If List1.List = gen Then
'I don't know what to do from here
'(how to go back to generate another number)
Next n
Next i
Thank you in advance
keep in minde I need to keep things simple
Thank you soo much
Use a boolean value to keep the result if same value generated is in list.
Private Sub AddRandomNumbers()
Dim blnIfFound As Boolean
Dim max As Integer
Dim min As Integer
Dim answers As Integer
max = 10
min = 1
answers = 5
Randomize
Do While List1.ListCount < answers
generated = CInt(Int((max - min + 1) * Rnd() + min))
blnIfFound = False
For n = 0 To List1.ListCount
If List1.List(n) = generated Then
blnIfFound = True
Exit For
End If
Next n
If blnIfFound = False Then List1.AddItem (generated)
Loop
End Sub

How to get values in reverse with loops

The issue is with the bottom of my code where I have to get the program to recite the entered values in reverse order. I think it might be something to do with the index?
Option Explicit On
Option Strict On
'Author: Murray Spears
'Date: October 12th 2012
'Write a program that accepts five input values and stores them into an array.
'Then display numbers in reverse order.
'Then display the average number, and all numbers that are are above average.
Imports System
Module Values
Sub Main()
Dim Number(4) as Integer
Dim Average as Double = 0
Dim Index as integer
'
For Index = 0 to 4
Console.Write("Enter number: ")
Number(Index)=Convert.ToInt32(Console.Readline())
Next Index
'Figure out the average for all the entered values.
Average = (Number(0)+Number(1)+Number(2)+Number(3)+Number(4))/5
Console.Writeline("The average of the numbers is: " &Average)
Console.Write("Numbers that are greater than the average: ")
Index = 4
Do until Index = 0
If Number(Index) > Average then
Console.Writeline(Number(Index))
End If
Index -=1
Loop
Console.Writeline("Numbers in reverse order: ")
Index = 4
Do while Number(index) > 0
Console.Writeline(Number(Index))
Number(index) -= 1
Loop
End Sub
End Module
Use Step -1 to step backwards.
For Index = 4 To 0 Step -1
' do your thing
Next
Imo, the simplest way is to just use a loop as you did when you entered the numbers but as you wrote yourself make the indexes go in reverse.
This is what the "Step -1" is for.
For Index As Integer = 4 To 0 Step -1
Console.Writeline(Number(Index))
Next

VBA Excel Inserting a row on outline level 3 comes in on outline level 2

Here's the problem. When there is only one row in a subtotal grouping:
the inserted row doesn't come in at the right outlinelevel.
the subtotal doesn't automatically include the inserted cell.
And here's the code that inserts the row (i is defined earlier):
For j = 2 To lEndRow * (1.5)
If InStr(Cells(j, i), "Total") Then
Cells(j - 1, i).EntireRow.Insert
With Cells(j - 1, i)
.EntireRow.Font.ColorIndex = 3
.EntireRow.Interior.ColorIndex = 2
End With
Cells(j - 1, i).EntireRow.OutlineLevel = 2 ' This didn't work,
' it puts all the inserted rows at 2 but doesn't group it
' the subtotal.
Cells(j - 1, i + 8) = "1% Discount within terms"
Cells(j - 1, i + 24).FormulaR1C1 = "=Round((R[2]C[-8])*(.01),2)"
j = j + 1
End If
Next
I imagine this is an easy problem if you know it. I just don't know it and it's gotten me pretty frustrated. Happy first post to me and happy holidays to you.
This is a guess but I think it is worth a try.
From MS Help's About outlining a worksheet
"Data to be outlined should be in range, where each column has a label in the first row and contains similar facts, and there are no blank rows or columns [my highlighting] within the range."
At the time you set the outline, the sub-total row is blank so cannot be part of the range. Try:
Cells(j - 1, i + 8) = "1% Discount within terms"
Cells(j - 1, i + 24).FormulaR1C1 = "=Round((R[2]C[-8])*(.01),2)"
Cells(j - 1, i).EntireRow.OutlineLevel = 2
Best of luck.

Resources