I use public variables a lot. In another thread I have been advised to stay away form them as much as possible.
Does the use of public variables have any effect on the performance of a database? Especially a database consisting of a front and back end running over a network?
I make use of public variables because I don't know to pass data. One example is the following:
I have a form for invoicing. Rather than have a combo box on the form to select an invoice (I have over 30,000) I open a pop up form showing a list of invoices. (I can filter the records returned in the list by date). When the user selects an invoice from the list I write the invoice id to a public variable. When the pop up form closes I use the public variable to open the correct record on the form.
On frmInvoice
On frmSeelctInvoiceToOpen
How would I do this without using a public variable?
Looking forward to a good debate on this!
Thanks in advance
Does the use of public variables have any effect on the performance of a database? Especially a database consisting of a front and back end running over a network?
I make use of public variables because I don't know to pass data. One example is the following:
I have a form for invoicing. Rather than have a combo box on the form to select an invoice (I have over 30,000) I open a pop up form showing a list of invoices. (I can filter the records returned in the list by date). When the user selects an invoice from the list I write the invoice id to a public variable. When the pop up form closes I use the public variable to open the correct record on the form.
On frmInvoice
Code:
Private Sub cmdSelectInvoice_Click()
intInvoiceId = 0
DoCmd.OpenForm "frmSelectInvoiceToOpen", acNormal, , , , acDialog
If intInvoiceId <> 0 Then
Me.RecordSource = "SELECT * From tblInvoice WHERE InvoiceId = " & intInvoiceId
End If
End Sub
Code:
Private Sub lstInvoice_AfterUpdate()
intInvoiceId = Me.lstInvoice
DoCmd.Close
End Sub
Looking forward to a good debate on this!
Thanks in advance