Hi all,
My last obstacle before finishing a big database is getting the summary form correct. This is going to be a long post, but i need help to make my VBA code simpler (if possible). Right now it takes about 15 seconds to do all the DLookup`s.
I have an unbound form (frmSummary). There are no bound controls on this form.
I have 2 comboboxes (cboPerson and cboPlace) and 45 unbound textboxes. The textboxes are ordered like this on the form:
TOTAL ------ SENT ------ OUT ------ IN STORAGE
Cellphone: [txtbox1] --- [txtbox2] ---- [txtbox3]
Computer: [txtbox 4] --- txtbox5] ----- [txtbox6]
And so on.
The textboxes are set to show the total number of that specific item. If the user wants he can filter the results from one of the two comboboxes, showing for examples "Computers" belonging to personA.
With 45 different textboxes that can be filtered in 3 different ways (person, place and no-filter) I end up with about 150 lines of code in 3 different events: formLoad, cboBox AfterUpdate (2 cboboxes) and no-filter_Click. Totalling to about 600 lines of code.
An example of the un-filtered code for cellphone:
Me.txtbox1= DCount("[Beslagtype]", "tblbeslagsoversikt", "[Beslagtype]='Cellphone'")
Me.txtbox2= DCount("[Beslagtype]", "tblbeslagsoversikt", "[Beslagtype]='Cellphone' And [SentOut]=false")
Me.txtbox3= DCount("[Beslagtype]", "tblbeslagsoversikt", "[Beslagtype]='Cellphone' And [SentOut]=true")
If filtered by one of the comboboxes the code simply adds this line in the criteria: And [Place] = '" & Me.txtPlace & "'"). This happens in the afterUpdate event of the combobox.
What I want is to make this with much less code so that the calculations goes much faster.
Is it possible to make several strings, use Recordset or something like that (I got not experience with neither). Or maybe it is better to make the textboxes bound to a query, adding criteria with the comboboxes?
Any help is appreciated. After solving this last problem I will be finished
My last obstacle before finishing a big database is getting the summary form correct. This is going to be a long post, but i need help to make my VBA code simpler (if possible). Right now it takes about 15 seconds to do all the DLookup`s.
I have an unbound form (frmSummary). There are no bound controls on this form.
I have 2 comboboxes (cboPerson and cboPlace) and 45 unbound textboxes. The textboxes are ordered like this on the form:
TOTAL ------ SENT ------ OUT ------ IN STORAGE
Cellphone: [txtbox1] --- [txtbox2] ---- [txtbox3]
Computer: [txtbox 4] --- txtbox5] ----- [txtbox6]
And so on.
The textboxes are set to show the total number of that specific item. If the user wants he can filter the results from one of the two comboboxes, showing for examples "Computers" belonging to personA.
With 45 different textboxes that can be filtered in 3 different ways (person, place and no-filter) I end up with about 150 lines of code in 3 different events: formLoad, cboBox AfterUpdate (2 cboboxes) and no-filter_Click. Totalling to about 600 lines of code.
An example of the un-filtered code for cellphone:
Me.txtbox1= DCount("[Beslagtype]", "tblbeslagsoversikt", "[Beslagtype]='Cellphone'")
Me.txtbox2= DCount("[Beslagtype]", "tblbeslagsoversikt", "[Beslagtype]='Cellphone' And [SentOut]=false")
Me.txtbox3= DCount("[Beslagtype]", "tblbeslagsoversikt", "[Beslagtype]='Cellphone' And [SentOut]=true")
If filtered by one of the comboboxes the code simply adds this line in the criteria: And [Place] = '" & Me.txtPlace & "'"). This happens in the afterUpdate event of the combobox.
What I want is to make this with much less code so that the calculations goes much faster.
Is it possible to make several strings, use Recordset or something like that (I got not experience with neither). Or maybe it is better to make the textboxes bound to a query, adding criteria with the comboboxes?
Any help is appreciated. After solving this last problem I will be finished
