MsgBox

S

Steve Moss

When a report is open I have a MsgBox which also opens, asking "would you
like to print this document". If the operator Clicks on "no", then the
MsgBox disappears, if they Click on "Yes" another MsgBox opens asking "how
many copies would you like". is there a way to add field to this MsgBox into
which the user can input a number of copies they would like, and then for it
to produce the correct number.

Cheers Steve
 
T

Tim Johnson

You may want to try creating a pop-up form instead of a msgbox for this. In
the macro or vba where you currenlty have your MsgBox, replace it with an
OpenForm command. Make sure the forms properties are set to PopUp and Modal.

On the form you can have either an options box using buttons for Print or
Cancel, Yes or Now, whatever you fancy and an unbound textbox for the number
of copies. For the OnClick event of "Yes", use this code:

Dim intCopies as Integer

For intCopies = 1 to me.textbox
DoCmd.OpenReport "ReportName"
Next intCopies

And for the 'No' button, use the code:

DoCmd.Close acForm, "PopUpFormName"
 
T

Tim Johnson

Glad to hear it worked well for you (especially considering how wrought with
typos it was)!

Cheers,
Tim
 
S

Steve Moss

Yeah it works great. my next question, if no value has been entered into the
textbox and the user selects "yes" an "invalid use of null" error pops up, is
there a way to have this message display something like "you need to insert a
number" instead of an error code.
Cheers
 
T

Tim Johnson

Sure. In the code prior to the loop, type in this

If isnull(me.textbox)=true then
MsgBox("Surely, you would like at least ONE copy!")
Else:


then add an End If at the end of the code.
 
S

Steve Moss

sorry a reply has taken so long, that forces only let us log on for a certain
lenght of time at certain times of the day. I will give it a go.
Many thanks
Steve
 
T

Tim Johnson

Steve, another suggestion on this, you may want to set the text box's default
value to 1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top