Hi,
I have an address book for my customers, and once they've completed a transaction I want to generate a receipt. The way I've done this so far is to have a field in the orders table called 'GenerateReceipt', and a button called 'GenerateReceiptButton' for each record in my tabular orders form which ultimately opens a report with just the details of that particular customer. It works like this:
When the button is pressed, it ticks the checkbox, then runs a macro which moves to the next record and then back to the current one (this is to save the status of that checkbox into the appropriate table/query), and then opens the report. The report gets its data from a query containing only the customer details who have 'GenerateReceipt' ticked, i.e. the customer whose details I just clicked the 'GenerateReceiptButton' for.
This all works fine. The only other thing I want to do is when the report has been generated and focus comes back to the form (or everything is closed for that matter), I want to untick the checkbox, so all checkboxes are false as they originally were. I originally did this by me.GenerateReceipt = False in the form current property, but when I try to generate a receipt for the last customer it reports a runtime error 'Cannot add record; join key of tblOrders not in recordset'. So if I then add the necessary join fields into the recordset and try again, it then doesn't allow me to add new records, meaning if you want to generate a receipt for the last customer in the field, there isn't a 'next' field for the macro to go to. So either way I'm stuck. If I remove the me.GenerateReceipt = False from the form current property, this error goes away.
I tried the same code in several other form properties, e.g. form_close, form_deactivate, form_lostfocus, form_gotfocus, but none of these did anything. What is the property I'm looking for? How do I get these checkboxes to clear once I either ideally come back to the form or less ideally close the form?
The only other avenue if anyone has ideas is another way to save the status of the checkboxes without going from one record to another. I tried several avenues including saving the form, query or table, but none seemed to work.
Thx in anticipation!
I have an address book for my customers, and once they've completed a transaction I want to generate a receipt. The way I've done this so far is to have a field in the orders table called 'GenerateReceipt', and a button called 'GenerateReceiptButton' for each record in my tabular orders form which ultimately opens a report with just the details of that particular customer. It works like this:
When the button is pressed, it ticks the checkbox, then runs a macro which moves to the next record and then back to the current one (this is to save the status of that checkbox into the appropriate table/query), and then opens the report. The report gets its data from a query containing only the customer details who have 'GenerateReceipt' ticked, i.e. the customer whose details I just clicked the 'GenerateReceiptButton' for.
This all works fine. The only other thing I want to do is when the report has been generated and focus comes back to the form (or everything is closed for that matter), I want to untick the checkbox, so all checkboxes are false as they originally were. I originally did this by me.GenerateReceipt = False in the form current property, but when I try to generate a receipt for the last customer it reports a runtime error 'Cannot add record; join key of tblOrders not in recordset'. So if I then add the necessary join fields into the recordset and try again, it then doesn't allow me to add new records, meaning if you want to generate a receipt for the last customer in the field, there isn't a 'next' field for the macro to go to. So either way I'm stuck. If I remove the me.GenerateReceipt = False from the form current property, this error goes away.
I tried the same code in several other form properties, e.g. form_close, form_deactivate, form_lostfocus, form_gotfocus, but none of these did anything. What is the property I'm looking for? How do I get these checkboxes to clear once I either ideally come back to the form or less ideally close the form?
The only other avenue if anyone has ideas is another way to save the status of the checkboxes without going from one record to another. I tried several avenues including saving the form, query or table, but none seemed to work.
Thx in anticipation!