Further simple Form questions

S

Stuart

1 form containing 1 frame. Within the frame are labels and textboxes, with
the idea that labels are fixed, and users simply enter their data in the
adjacent textboxes.

So far I have no code, but I will show the form via an addin's menu.

Q1: how do I return the user from the form (ie back to the addin)?
Q2: how does the user save the form?
Q3: how does the user print the form?

Any help would be much appreciated.

Regards.
 
T

Tom Ogilvy

Private Sub CommandButton1_click()
Userform1.PrintForm
unload me
End Sub


write the data somewhere. You don't save the userform.
 
B

Bob Phillips

If you mean that you want to preserve whatever was on the form when you say
save it, then you will have to save all of the textbox, combobox values etc
onto a worksheet in the addin, and next time the form is shown, then you
load the form from that worksheet data.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
S

Stuart

Many thanks for the reply.

So I have to place a 'Print' button on the Form for the
user to click? Will this show up in the print?

Regards.
 
B

Bob Phillips

In the Userform_Terminate event add code like

With ThisWorkbook.Worksheets("SaveForm")
.Range("A1").Value = Me.Textbox1.Value
.Range("A2").Value = Me.ComboBox1.Value
'etc.
End With

You will have to adapt to all the controls that you wsih to save, I can't
possibly know all of that.

To reload, just do the opposite in the Userform_Initilaize event

With ThisWorkbook.Worksheets("SaveForm")
Me.Textbox1.Value = .Range("A1").Value
Me.ComboBox1.Value = .Range("A2").Value
'etc.
End With

One thing to be aware of is that loading the form in the initialize event
like this can trigger control event code.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

Bob Phillips

Normally it would, but you could try

Private Sub Print_Click()
Me.Print.Visible = False
Userform1.PrintForm
unload me
End Sub

If you don't want to unload the form after printing, just change that to

Me.Print.Visible = True

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
S

Stuart

Will give it a try.
Many thanks

Regards.

Bob Phillips said:
Normally it would, but you could try

Private Sub Print_Click()
Me.Print.Visible = False
Userform1.PrintForm
unload me
End Sub

If you don't want to unload the form after printing, just change that to

Me.Print.Visible = True

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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