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

Labels Dialog Box Enhancement

P: n/a
I have been using a module for printing labels in Access 97, and
although it works fine, I would like to add a small enhancement to it.
The module allows for setting the number of labels to print and/or to
skip; however, the Cancel command button does not function, nor does
clicking the X-close. Clicking either one is the same as clicking the
OK button.

Since the module creates and displays the dialog box, I will need a
piece of code to address the enhancement. A copy of the module is
posted below. Any assistance will be appreciated. Thanks, Dalan

Option Compare Database
Option Explicit

Dim LabelBlanks&
Dim LabelCopies&
Dim BlankCount&
Dim CopyCount&

Function LabelSetup()
LabelBlanks& = Val(InputBox$("Enter Number of Blank Labels to Skip"))
LabelCopies& = Val(InputBox$("Enter Number of Copies to Print"))
If LabelBlanks& < 0 Then LabelBlanks& = 0
If LabelCopies& < 1 Then LabelCopies& = 1
End Function

Function LabelInitialize()
BlankCount& = 0
CopyCount& = 0
End Function

Function LabelLayout(R As Report)
If BlankCount& < LabelBlanks& Then
R.NextRecord = False
R.PrintSection = False
BlankCount& = BlankCount& + 1
Else
If CopyCount& < (LabelCopies& - 1) Then
R.NextRecord = False
CopyCount& = CopyCount& + 1
Else
CopyCount& = 0
End If
End If
End Function
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> LabelBlanks& = Val(InputBox$("Enter Number of Blank Labels to Skip"))
LabelCopies& = Val(InputBox$("Enter Number of Copies to Print"))
Instead of Input Boxes, use a custom form that you design. Place 3 textboxes
on it, one for each entry, with Ok and Cancel buttons, and set the set the
Min/Max buttons, control box, and close button to None/No in the form's
Properties box. The 3rd textbox will be a hidden textbox that holds a value
indicating whether the Ok or Cancel button was clicked. Open the form using
the acDialog window mode argument with the DoCmd.OpenForm command. This will
cause your code to pause until you close or hide the popup form. Have the
buttons set the value in the hidden textbox and hide the form
(Me.Visible=False). In the line following the call to open the form, check
the value of the hidden textbox to see if Ok or Cancel was chosen. Depending
on the value of the hidden textboxes, get the values from the other 2
textboxes or react to the cancel. Remember to close the form when you close
the report.

--
Wayne Morgan
Microsoft Access MVP
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om... I have been using a module for printing labels in Access 97, and
although it works fine, I would like to add a small enhancement to it.
The module allows for setting the number of labels to print and/or to
skip; however, the Cancel command button does not function, nor does
clicking the X-close. Clicking either one is the same as clicking the
OK button.

Since the module creates and displays the dialog box, I will need a
piece of code to address the enhancement. A copy of the module is
posted below. Any assistance will be appreciated. Thanks, Dalan

Option Compare Database
Option Explicit

Dim LabelBlanks&
Dim LabelCopies&
Dim BlankCount&
Dim CopyCount&

Function LabelSetup()
LabelBlanks& = Val(InputBox$("Enter Number of Blank Labels to Skip"))
LabelCopies& = Val(InputBox$("Enter Number of Copies to Print"))
If LabelBlanks& < 0 Then LabelBlanks& = 0
If LabelCopies& < 1 Then LabelCopies& = 1
End Function

Function LabelInitialize()
BlankCount& = 0
CopyCount& = 0
End Function

Function LabelLayout(R As Report)
If BlankCount& < LabelBlanks& Then
R.NextRecord = False
R.PrintSection = False
BlankCount& = BlankCount& + 1
Else
If CopyCount& < (LabelCopies& - 1) Then
R.NextRecord = False
CopyCount& = CopyCount& + 1
Else
CopyCount& = 0
End If
End If
End Function

Nov 12 '05 #2

P: n/a
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<_X*******************@newssvr32.news.prodigy .com>...
LabelBlanks& = Val(InputBox$("Enter Number of Blank Labels to Skip"))
LabelCopies& = Val(InputBox$("Enter Number of Copies to Print"))


Instead of Input Boxes, use a custom form that you design. Place 3 textboxes
on it, one for each entry, with Ok and Cancel buttons, and set the set the
Min/Max buttons, control box, and close button to None/No in the form's
Properties box. The 3rd textbox will be a hidden textbox that holds a value
indicating whether the Ok or Cancel button was clicked. Open the form using
the acDialog window mode argument with the DoCmd.OpenForm command. This will
cause your code to pause until you close or hide the popup form. Have the
buttons set the value in the hidden textbox and hide the form
(Me.Visible=False). In the line following the call to open the form, check
the value of the hidden textbox to see if Ok or Cancel was chosen. Depending
on the value of the hidden textboxes, get the values from the other 2
textboxes or react to the cancel. Remember to close the form when you close
the report.

--
Wayne Morgan
Microsoft Access MVP
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
I have been using a module for printing labels in Access 97, and
although it works fine, I would like to add a small enhancement to it.
The module allows for setting the number of labels to print and/or to
skip; however, the Cancel command button does not function, nor does
clicking the X-close. Clicking either one is the same as clicking the
OK button.

Since the module creates and displays the dialog box, I will need a
piece of code to address the enhancement. A copy of the module is
posted below. Any assistance will be appreciated. Thanks, Dalan

Option Compare Database
Option Explicit

Dim LabelBlanks&
Dim LabelCopies&
Dim BlankCount&
Dim CopyCount&

Function LabelSetup()
LabelBlanks& = Val(InputBox$("Enter Number of Blank Labels to Skip"))
LabelCopies& = Val(InputBox$("Enter Number of Copies to Print"))
If LabelBlanks& < 0 Then LabelBlanks& = 0
If LabelCopies& < 1 Then LabelCopies& = 1
End Function

Function LabelInitialize()
BlankCount& = 0
CopyCount& = 0
End Function

Function LabelLayout(R As Report)
If BlankCount& < LabelBlanks& Then
R.NextRecord = False
R.PrintSection = False
BlankCount& = BlankCount& + 1
Else
If CopyCount& < (LabelCopies& - 1) Then
R.NextRecord = False
CopyCount& = CopyCount& + 1
Else
CopyCount& = 0
End If
End If
End Function

Thanks for your suggestion Wayne, but I don't think that I want create
a form for this process. There are several different labels that are
available in the database and to include them all on a selection
form(s) is not an optimal consideration. Really, the current code
generated popup box works well and I would like to stay with it. Just
a small enhancement to the code is all I need. Any assistance or
further suggestions will be welcomed. Thanks, Dalan
Nov 12 '05 #3

P: n/a
In that case, the Input Box should return a zero length string ("") if
Cancel is clicked. I just tested to make sure, but I show that the close box
(x) acts as if Cancel was clicked.

If this isn't the action you're seeing, I would recommend a Repair and a
Compact of the database (Tools|Database Utilities). The compact and the
repair are separate items in Access 97. If that doesn't work, then I would
try a decompile on a COPY of the database to see what happens.

--
Wayne Morgan
MS Access MVP
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<_X*******************@newssvr32.news.prodigy .com>...

Thanks for your suggestion Wayne, but I don't think that I want create
a form for this process. There are several different labels that are
available in the database and to include them all on a selection
form(s) is not an optimal consideration. Really, the current code
generated popup box works well and I would like to stay with it. Just
a small enhancement to the code is all I need. Any assistance or
further suggestions will be welcomed. Thanks, Dalan

Nov 12 '05 #4

P: n/a
> Function LabelSetup()
LabelBlanks& = Val(InputBox$("Enter Number of Blank Labels to Skip"))
LabelCopies& = Val(InputBox$("Enter Number of Copies to Print"))
If LabelBlanks& < 0 Then LabelBlanks& = 0
If LabelCopies& < 1 Then LabelCopies& = 1
End Function


You aren't doing anything here to check for the "" if Cancel was clicked.
Val("") evaluates to zero. This will set up 0 LabelBlanks. It is also less
than one for LabelCopies, which you are automatically substituting one.

--
Wayne Morgan
MS Access MVP
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.