stillwillyboy
Technical User
I have a Report whose Record Source is “qry-OrdersQuery”. This puts all the needed info onto the report (invoice) that I need except for the Invoice number.
I have a text box on the report (invoice) whose Control Source is “InvoiceNumber”. Invoice Number is a field in my Orders table that is linked in the
qry-OrdersQuery to the tables OrdersDetail, Parts, Branches, and Customers.
When I add to the “qry-OrdersQuery” query, the table named “InvoiceNumberList” that I am using to keep track of the used invoice numbers, the only orders that appear when I run qry-OrdersQuery are those that have a corresponding number in the InvoiceNumberList table, which I believe, is correct. But, even though the Show box is checked for InvoiceNumber, the invoice numbers do not appear on the datasheet or the report.
So my question are: how do I use the following code? Where do I place it to have it work? I know that it goes into the VBA module, but how do I call it? Does it belong to the table “InvoiceNumberList” or somewhere in “qry_OrdersQuery”? How do I get the Invoice numbers to appear in both the datasheet and the report?
Sub InvoiceNumber ()
If isnull(Me!txtInvoiceNo.Value) then
Me!txtInvoiceNo.Value=DMax("field",Table")+1
End if
End sub
The above code was provided by Roy-Vidar. I added the Sub and End Sub lines. Thanks Roy.
TIA. Bill
I have a text box on the report (invoice) whose Control Source is “InvoiceNumber”. Invoice Number is a field in my Orders table that is linked in the
qry-OrdersQuery to the tables OrdersDetail, Parts, Branches, and Customers.
When I add to the “qry-OrdersQuery” query, the table named “InvoiceNumberList” that I am using to keep track of the used invoice numbers, the only orders that appear when I run qry-OrdersQuery are those that have a corresponding number in the InvoiceNumberList table, which I believe, is correct. But, even though the Show box is checked for InvoiceNumber, the invoice numbers do not appear on the datasheet or the report.
So my question are: how do I use the following code? Where do I place it to have it work? I know that it goes into the VBA module, but how do I call it? Does it belong to the table “InvoiceNumberList” or somewhere in “qry_OrdersQuery”? How do I get the Invoice numbers to appear in both the datasheet and the report?
Sub InvoiceNumber ()
If isnull(Me!txtInvoiceNo.Value) then
Me!txtInvoiceNo.Value=DMax("field",Table")+1
End if
End sub
The above code was provided by Roy-Vidar. I added the Sub and End Sub lines. Thanks Roy.
TIA. Bill