Printing a form and a decimal Point Thing...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all:
I have 2 seperate problems,

1) I have a form where it is just a reciept and nothing more for what was
purchased at a show. I have in the price part of the form the decimal places
set to 2 but it will still show, .2 for 20 cents. I have what I feel is
everything, is there a soltion to this that I am missing.

2) Also, on the same form I have a print button that I would like to, when
clicked, print 2 coppies of the current form. Is there a way to do this?

thanks for any advice or help,
--
 
psquillace said:
Hello all:
I have 2 seperate problems,

1) I have a form where it is just a reciept and nothing more for what
was purchased at a show. I have in the price part of the form the
decimal places set to 2 but it will still show, .2 for 20 cents. I
have what I feel is everything, is there a soltion to this that I am
missing.

You probably have the Format property of the text box set to "General
Number". Set it to "Fixed" or "Currency", and it will respect your
setting for Decimal Places.
2) Also, on the same form I have a print button that I would like to,
when clicked, print 2 coppies of the current form. Is there a way to
do this?

See this link:

http://www.mvps.org/access/reports/rpt0001.htm
 
psquillace said:
Hello all:
I have 2 seperate problems,

1) I have a form where it is just a reciept and nothing more for what
was purchased at a show. I have in the price part of the form the
decimal places set to 2 but it will still show, .2 for 20 cents. I
have what I feel is everything, is there a soltion to this that I am
missing.

2) Also, on the same form I have a print button that I would like to,
when clicked, print 2 coppies of the current form. Is there a way to
do this?

thanks for any advice or help,

Note, by the way, that Access forms aren't really ideal for printing
directly. It would probably be better to make a report that looks like
the form, and print that out instead. You can get a jumpstart on such a
report by saving the form as a report (using menu items File -> Save
As...).
 
Thanks Dirk for all your help with this.

The # is already set to Currency, I tried setting it to fixed but with no
results. If I set it to 0 decimal places it seems to work but that is not the
result I am looking for.

As far as the printing thing,

I have this code in there -
stDocName = "Form1"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

so I should change the line DoCmd.PrintOut to DoCmd.Print,,,,2?

Thanks again for your help
 
psquillace said:
Thanks Dirk for all your help with this.

The # is already set to Currency, I tried setting it to fixed but
with no results. If I set it to 0 decimal places it seems to work but
that is not the result I am looking for.

Are you sure you set the Format property, on the property sheet of the
text box in the design view of the form? We're not concerned with the
field type of the field in the table. With the text box's Format
property set to "Currency" and its Decimal Places property set to 2, you
should always get two decimal places displayed on the form.
As far as the printing thing,

I have this code in there -
stDocName = "Form1"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

so I should change the line DoCmd.PrintOut to DoCmd.Print,,,,2?

That looks like a bit of a mish-mosh. Let's assume that you want to
print the currently active form. That would be the case if you're
triggering this from a command button on the form. Then all you'd need
is the one line

DoCmd.PrintOut , , , , 2

or, using an alternate syntax to avoid all those confusing commas,

DoCmd.PrintOut Copies:=2

Note that this is going to print out *all* records currently in the
form's recordset. So if the form currently displays multiple records,
and you want to print just the current one, and you really want to print
the form, not a report that is similar to the form, then your code will
need to filter the form before calling DoCmd.PrintOut, and maybe
"unfilter it" afterward. And then you'll probably want to get back to
the record you were on, since removing the filter will reposition the
form to the first record in its recordsource. All this makes your code
more complicated:

'----- start of example code -----
Dim varID As Variant

' Make sure the current record has been saved.
If Me.Dirty Then Me.Dirty = False

' Remember which record we're currently on.
' [ID] is the primary key of this form's recordsource.

varID = Me.ID

' Filter the form for just that record.
Me.Filter = "ID=" & varID
Me.FilterOn = True

' Print out the form.
DoCmd.PrintOut Copies:=2

' Remove the filter.
Me.FilterOn = False

' Reposition the form to the record we were on.
Me.Recordset.FindFirst "ID=" & varID
'----- end of example code -----

Printing out a report would be simpler.
 
Thanks Dirk, I got the form to print 2 copies now.

As far as the decimal point, I still have not found a solution and I even
checked with the data in my table to make sure that it was 2 decimal places
there as well.

Any other recomendations will be much appreciated.


--
-------------------------
I only speak in php/mySQL
so excuse my english....
-------------------------
http://www.gzws.com


Dirk Goldgar said:
psquillace said:
Thanks Dirk for all your help with this.

The # is already set to Currency, I tried setting it to fixed but
with no results. If I set it to 0 decimal places it seems to work but
that is not the result I am looking for.

Are you sure you set the Format property, on the property sheet of the
text box in the design view of the form? We're not concerned with the
field type of the field in the table. With the text box's Format
property set to "Currency" and its Decimal Places property set to 2, you
should always get two decimal places displayed on the form.
As far as the printing thing,

I have this code in there -
stDocName = "Form1"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

so I should change the line DoCmd.PrintOut to DoCmd.Print,,,,2?

That looks like a bit of a mish-mosh. Let's assume that you want to
print the currently active form. That would be the case if you're
triggering this from a command button on the form. Then all you'd need
is the one line

DoCmd.PrintOut , , , , 2

or, using an alternate syntax to avoid all those confusing commas,

DoCmd.PrintOut Copies:=2

Note that this is going to print out *all* records currently in the
form's recordset. So if the form currently displays multiple records,
and you want to print just the current one, and you really want to print
the form, not a report that is similar to the form, then your code will
need to filter the form before calling DoCmd.PrintOut, and maybe
"unfilter it" afterward. And then you'll probably want to get back to
the record you were on, since removing the filter will reposition the
form to the first record in its recordsource. All this makes your code
more complicated:

'----- start of example code -----
Dim varID As Variant

' Make sure the current record has been saved.
If Me.Dirty Then Me.Dirty = False

' Remember which record we're currently on.
' [ID] is the primary key of this form's recordsource.

varID = Me.ID

' Filter the form for just that record.
Me.Filter = "ID=" & varID
Me.FilterOn = True

' Print out the form.
DoCmd.PrintOut Copies:=2

' Remove the filter.
Me.FilterOn = False

' Reposition the form to the record we were on.
Me.Recordset.FindFirst "ID=" & varID
'----- end of example code -----

Printing out a report would be simpler.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top