Buttons on continuous form

drazen

Registered User.
Local time
Today, 14:51
Joined
Jan 28, 2016
Messages
31
Hi, Can anyone help please!
I am trying to develop a 'Print copy invoice' form

I have a continuous form with the following fields (already issued invoices)

Date / Invoice / Description / amount / [Button]

I am trying to print the invoice on the line then the button is pressed. (there could be 100's of Invoices listed. I need to pass the invoice number value to either a Macro or vba script, which ever is easiest. But i'm struggling.

I keep getting the pop up box telling me to put in the invoice number.

Can anyone point me in the right direction please?

Thanks.
 
What code do you currently have and is the InvoiceNumber field in the underlying data for the continuous form?
 
I'm currently using a macro, but i dont mind using VBA if its easier. the invoice number changes on each line, so the button must be able to pass on this number. but I'm not sure how i do that
 
So - how are you doing it at the moment?
In VBA the value of any control on the current record is available to you though the use of Me.YourControlName

So you could set a variable to your invoice number control (if it was called txtInvNo) with
Code:
Private Sub [I]cmdYourButton[/I]_OnCLick()

Dim sInvoiceNo as String 

If IsNull(Me.txtInvNo) Then Exit Sub [COLOR="Green"]' Don't process the rest if it's null[/COLOR]
sInvoiceNo = Me.txtInvNo

Do some other stuff here

End Sub
 
Last edited:
Thanks for your help.
A strange this is happening, If i use a macro the button triggers it fine, but when I use VBA I get nothing, no trigger at all.
I have lots of controls on the parent form, this is the first control on the subform (the VBA is empty).

The continuous form is a sub form, I think this may have something to do with it.

this is the form
I need to click print and it prints the Invoice from the invoice table where invoice number is the invoice number in the same line as the print button.

Image1.jpg
 
In design view of the sub form - when you click the on click event of the Print button what code do you have?
You can't have both VBA and a macro assigned at the same time. It's one or the other.
 
I did delete the Macro on the Event property before I did wrote the VBA.
This didn't work, so I deleted the button, created another button and called it something different. That did work.

Thanks for your help, all working great now.
 
Glad you have it sorted out!
If you want to tidy up the multiple buttons you can put the button(s) in the sub form header or footer without any code modification. Then you only have one button.

Alternatively you could put the button on your main form and refer to the sub forms current record using;
Code:
Me![I]YourSubFormName[/I].Form![I]YourControlName[/I]
 

Users who are viewing this thread

Back
Top Bottom