Re: CHECK FIELD FOR PRINTING
- From: "Wayne Veale" <venterp@xxxxxxxxxxxxxxx>
- Date: Fri, 16 Jun 2006 14:23:34 -0400
Re: CHECK FIELD FOR PRINTINGJoe,
Thank you very very much for the response and code. WWV
"Joseph R. Pottschmidt" <me@xxxxxxxxxxxxxxxxxx> wrote in message news:00a001c690e8$f3f9e1d0$640fa8c0@xxxxxxxxxxx
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:venterp@xxxxxxxxxxxxxxx]
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
"Joseph R. Pottschmidt" <me@xxxxxxxxxxxxxxxxxx> wrote in message news:006601c68536$b60c37a0$650fa8c0@xxxxxxxxxxx
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:venterp@xxxxxxxxxxxxxxx]
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
- References:
- Re: CHECK FIELD FOR PRINTING
- From: Wayne Veale
- Re: CHECK FIELD FOR PRINTING
- From: Joseph R. Pottschmidt
- Re: CHECK FIELD FOR PRINTING
- Prev by Date: Re: Macro for Error Message
- Next by Date: Re: email / hyperlink field / outlook express taking over
- Previous by thread: Re: CHECK FIELD FOR PRINTING
- Next by thread: Re: Find code errors
- Index(es):
Loading