CHECK FIELD FOR PRINTING

W

Wayne Veale

I have a field on a tbl I update witha update query. I want to check that
field, that record, for >= 50.00. If it is, I want to show a form asking if
usr wants to print a report (coupon) or not. If yes, I want to subtract
50.00 from the fld and print the rpt, if not, end. I tried using qry and
macro but can't get it. (I'm still a newbe)
Thanks WWV
 
J

Joseph R. Pottschmidt

Dear Wayne:

Due to the limits of what you can update and what macro's can do, there
isn't anyway to have a macro ask a question and then take action based
on that answer unless those buttons are on the form, and even then
getting the values after the question has been asked is a little tricky.

I can give you VBA code examples where that can be done within VBA code
without to much programming?

If you would like me to post that, I would be more than happy to work it
out for you and post the code of how it can be done in VBA.

Most of it is under 15 lines of VBA code and a lot easier to read as
well.

Joe P.


-----Original Message-----
From: Wayne Veale [mailto:[email protected]]
Posted At: Wednesday, May 17, 2006 7:33 PM
Posted To: microsoft.public.access.macros
Conversation: CHECK FIELD FOR PRINTING
Subject: CHECK FIELD FOR PRINTING

I have a field on a tbl I update witha update query. I want to check
that
field, that record, for >= 50.00. If it is, I want to show a form asking
if
usr wants to print a report (coupon) or not. If yes, I want to subtract
50.00 from the fld and print the rpt, if not, end. I tried using qry and

macro but can't get it. (I'm still a newbe)
Thanks WWV
 
W

Wayne Veale

Re: CHECK FIELD FOR PRINTINGJoe, Sorry it took so long to get back to you but I have been out of town. Please send code on this. I'm an old ex programmer and this has been a frustrating problem for me. I basically want to check a table entry (I know how to identify this) and display a form if the value is in a field >= 50. The form mearly asks if the usr wants to print a report (coupon) or not. This form is created and working on it's own. I did not think it would be a problem shooting a form based on a condition. One problem is if the condition IS met, it seems to work fine, if the condition IS NOT met, the form is displayed with no informations in the fields. Pleeeese help,
WWV
Dear Wayne:

Due to the limits of what you can update and what macro's can do, there isn't anyway to have a macro ask a question and then take action based on that answer unless those buttons are on the form, and even then getting the values after the question has been asked is a little tricky.

I can give you VBA code examples where that can be done within VBA code without to much programming?

If you would like me to post that, I would be more than happy to work it out for you and post the code of how it can be done in VBA.

Most of it is under 15 lines of VBA code and a lot easier to read as well.

Joe P.



-----Original Message-----
From: Wayne Veale [mailto:[email protected]]
Posted At: Wednesday, May 17, 2006 7:33 PM
Posted To: microsoft.public.access.macros
Conversation: CHECK FIELD FOR PRINTING
Subject: CHECK FIELD FOR PRINTING

I have a field on a tbl I update witha update query. I want to check that
field, that record, for >= 50.00. If it is, I want to show a form asking if
usr wants to print a report (coupon) or not. If yes, I want to subtract
50.00 from the fld and print the rpt, if not, end. I tried using qry and
macro but can't get it. (I'm still a newbe)
Thanks WWV
 
J

Joseph R. Pottschmidt

Dear Wayne:



Here is what you need to do in order to make what you want to happen in
VBA code:

Please make sure in your reference Library to install the Microsoft DAO
Library Support in order for the Database options to work. Otherwise it
will not show up as a Unknown referenced item in your code.



Sub PrintCoupon()

Dim MyDB As DAO.Database ' Defines a variable as a Database
Reference

Dim MyRS As DAO.Recordset ' Defines a variable as a Recordset
Reference

Dim Ans As Integer 'Defines a variable to store the answer to
question



Set MyDB = CurrentDb() 'Sets the MyDB variable to the current open
database.

'Set the MyRS variable with an SQL Statement that will Pull all
records that will have an amount >= $50 and allows you to Edit it

Set MyRS = MyDB.OpenRecordset("Coupon", DB_OPEN_DYNASET)

'These next lines of code go through the condition of each record
that was true and allows to answer the question if you want to print or
not.

Criteria = "AmountField >= 50"

MyRS.FindFirst Criteria

Do While Not MyRS.EOF()

Ans = MsgBox("Do you want to Print Coupon?", vbYesNo, "Printing
Coupon")

If Ans = vbYes Then

DoCmd.OpenReport "Coupon", acViewNormal 'This is the report
that has your coupon designed with the $50.00 on it.

MyRS.Edit

MyRS!AmountField = MyRS!AmountField - 50

MyRS.Update

MyRS.FindNext Criteria

Else

MyRS.FindNext Criteria

End If



Loop

End Sub

_____

From: Wayne Veale [mailto:[email protected]]
Posted At: Wednesday, June 14, 2006 8:31 PM
Posted To: microsoft.public.access.macros
Conversation: CHECK FIELD FOR PRINTING
Subject: Re: CHECK FIELD FOR PRINTING


Joe, Sorry it took so long to get back to you but I have been out of
town. Please send code on this. I'm an old ex programmer and this has
been a frustrating problem for me. I basically want to check a table
entry (I know how to identify this) and display a form if the value is
in a field >= 50. The form mearly asks if the usr wants to print a
report (coupon) or not. This form is created and working on it's own. I
did not think it would be a problem shooting a form based on a
condition. One problem is if the condition IS met, it seems to work
fine, if the condition IS NOT met, the form is displayed with no
informations in the fields. Pleeeese help,

WWV


Dear Wayne:

Due to the limits of what you can update and what macro's can do, there
isn't anyway to have a macro ask a question and then take action based
on that answer unless those buttons are on the form, and even then
getting the values after the question has been asked is a little tricky.

I can give you VBA code examples where that can be done within VBA code
without to much programming?

If you would like me to post that, I would be more than happy to work it
out for you and post the code of how it can be done in VBA.

Most of it is under 15 lines of VBA code and a lot easier to read as
well.

Joe P.



-----Original Message-----
From: Wayne Veale [mailto:[email protected]]
Posted At: Wednesday, May 17, 2006 7:33 PM
Posted To: microsoft.public.access.macros
Conversation: CHECK FIELD FOR PRINTING
Subject: CHECK FIELD FOR PRINTING

I have a field on a tbl I update witha update query. I want to check
that
field, that record, for >= 50.00. If it is, I want to show a form asking
if
usr wants to print a report (coupon) or not. If yes, I want to subtract
50.00 from the fld and print the rpt, if not, end. I tried using qry and

macro but can't get it. (I'm still a newbe)
Thanks WWV
 
W

Wayne Veale

Re: CHECK FIELD FOR PRINTINGJoe,
Thank you very very much for the response and code. WWV
Dear Wayne:



Here is what you need to do in order to make what you want to happen in VBA code:

Please make sure in your reference Library to install the Microsoft DAO Library Support in order for the Database options to work. Otherwise it will not show up as a Unknown referenced item in your code.



Sub PrintCoupon()

Dim MyDB As DAO.Database ' Defines a variable as a Database Reference

Dim MyRS As DAO.Recordset ' Defines a variable as a Recordset Reference

Dim Ans As Integer 'Defines a variable to store the answer to question



Set MyDB = CurrentDb() 'Sets the MyDB variable to the current open database.

'Set the MyRS variable with an SQL Statement that will Pull all records that will have an amount >= $50 and allows you to Edit it

Set MyRS = MyDB.OpenRecordset("Coupon", DB_OPEN_DYNASET)

'These next lines of code go through the condition of each record that was true and allows to answer the question if you want to print or not.

Criteria = "AmountField >= 50"

MyRS.FindFirst Criteria

Do While Not MyRS.EOF()

Ans = MsgBox("Do you want to Print Coupon?", vbYesNo, "Printing Coupon")

If Ans = vbYes Then

DoCmd.OpenReport "Coupon", acViewNormal 'This is the report that has your coupon designed with the $50.00 on it.

MyRS.Edit

MyRS!AmountField = MyRS!AmountField - 50

MyRS.Update

MyRS.FindNext Criteria

Else

MyRS.FindNext Criteria

End If



Loop

End Sub


------------------------------------------------------------------------------

From: Wayne Veale [mailto:[email protected]]
Posted At: Wednesday, June 14, 2006 8:31 PM
Posted To: microsoft.public.access.macros
Conversation: CHECK FIELD FOR PRINTING
Subject: Re: CHECK FIELD FOR PRINTING


Joe, Sorry it took so long to get back to you but I have been out of town. Please send code on this. I'm an old ex programmer and this has been a frustrating problem for me. I basically want to check a table entry (I know how to identify this) and display a form if the value is in a field >= 50. The form mearly asks if the usr wants to print a report (coupon) or not. This form is created and working on it's own. I did not think it would be a problem shooting a form based on a condition. One problem is if the condition IS met, it seems to work fine, if the condition IS NOT met, the form is displayed with no informations in the fields. Pleeeese help,

WWV


Dear Wayne:

Due to the limits of what you can update and what macro's can do, there isn't anyway to have a macro ask a question and then take action based on that answer unless those buttons are on the form, and even then getting the values after the question has been asked is a little tricky.

I can give you VBA code examples where that can be done within VBA code without to much programming?

If you would like me to post that, I would be more than happy to work it out for you and post the code of how it can be done in VBA.

Most of it is under 15 lines of VBA code and a lot easier to read as well.

Joe P.



-----Original Message-----
From: Wayne Veale [mailto:[email protected]]
Posted At: Wednesday, May 17, 2006 7:33 PM
Posted To: microsoft.public.access.macros
Conversation: CHECK FIELD FOR PRINTING
Subject: CHECK FIELD FOR PRINTING

I have a field on a tbl I update witha update query. I want to check that
field, that record, for >= 50.00. If it is, I want to show a form asking if
usr wants to print a report (coupon) or not. If yes, I want to subtract
50.00 from the fld and print the rpt, if not, end. I tried using qry and
macro but can't get it. (I'm still a newbe)
Thanks WWV
 

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