Χαιρετώ την μεγάλη παρέα του φόρουμ,
Το πρόβλημα που αναρτώ σήμερα πιστεύω πως σε κάποια φάση θα απασχόλησε ή ίσως ακόμη και να απασχολεί αρκετούς φίλους του φόρουμ που ασχολούνται ή έστω σε κάποια φάση μπορεί να ασχοληθούν με την δημιουργία μεγάλων βάσεων όπως και στην δικιά μου περίπτωση.
Λοιπόν,
Στην βάση που ασχολούμαι τα τελευταία 2 τουλάχιστον χρόνια και αφορά ένα κεφάλαιο ιατρικής και υγείας ατόμων, δυστυχώς πρέπει να επεξεργάζομαι πάρα πολλά δεδομένα καθώς επίσης και αρκετούς πίνακες απο τον Π.Ο.Υ (Παγκόσμιο Οργανισμό Υγείας). Έτσι λοιπόν δυστυχώς έχω αρκετό κώδικα
Vba στην βάση μου και μάλιστα σε αρκετές περιπτώσεις είναι και πολύ μακροσκελείς...! Εξαιτίας όμως ελλειπων γνωσεων ίσως (και μάλλον κάπως έτσι θα έχουν τα πράγματα) ο μεγάλος κώδικας μπορεί να ωφείλεται εξαιτίας ακριβώς των ελλειπών γνώσεων μου σε
Vba ενώ εάν αυτό θα το διαχειριζόταν ίσως κάποιος άλλος πιο έμπειρος απο εμένα ......ίσως και ο κώδικας να ήταν μάλλον και ο μισός..!!
Θα εκτιμήσω εάν κάποιος έμπειρος φίλος κοιτάξει το πιο κάτω παράδειγμα ενός απο αυτούς τους μεγάλους κώδικες που ανάφερα πιο πρίν, και να μου παραθέσει την γνώμη ή έστω την ιδέα του εάν και κατά πόσο θα μπορούσα να τον γράψω αλιώς έτσι ώστε να είναι αφενός μεν και πιο μικρός αλλά ίσως και πιο λειτουργικός..!!
Private Sub cboUnit_AfterUpdate()
'Calcium
If Me.ctr1 = 1 Then
Me.T1 = Me.Calcium
Me.T1.Requery
Else
If Me.ctr1 = 2 Then
Me.T1 = Me.Calcium * 1000
Me.T1.Requery
Else
If Me.ctr1 = 3 Then
Me.T1 = Me.Calcium / 1000
Me.T1.Requery
Else
If Me.ctr1 = 10 Then
Me.T1 = Me.Calcium / 1000
Me.T1.Requery
Else
If Me.ctr1 = 20 Then
Me.T1 = Me.Calcium
Me.T1.Requery
Else
If Me.ctr1 = 30 Then
Me.T1 = Me.Calcium / 1000000
Me.T1.Requery
Else
If Me.ctr1 = 100 Then
Me.T1 = Me.Calcium * 1000
Me.T1.Requery
Else
If Me.ctr1 = 200 Then
Me.T1 = Me.Calcium * 1000000
Me.T1.Requery
Else
If Me.ctr1 = 300 Then
Me.T1 = Me.Calcium
Me.T1.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ....
'Chromium
If Me.ctr2 = 1 Then
Me.T2 = Me.Chromium
Me.T2.Requery
Else
If Me.ctr2 = 2 Then
Me.T2 = Me.Chromium * 1000
Me.T2.Requery
Else
If Me.ctr2 = 3 Then
Me.T2 = Me.Chromium / 1000
Me.T2.Requery
Else
If Me.ctr2 = 10 Then
Me.T2 = Me.Chromium / 1000
Me.T2.Requery
Else
If Me.ctr2 = 20 Then
Me.T2 = Me.Chromium
Me.T2.Requery
Else
If Me.ctr2 = 30 Then
Me.T2 = Me.Chromium / 1000000
Me.T2.Requery
Else
If Me.ctr2 = 100 Then
Me.T2 = Me.Chromium * 1000
Me.T2.Requery
Else
If Me.ctr2 = 200 Then
Me.T2 = Me.Chromium * 1000000
Me.T2.Requery
Else
If Me.ctr2 = 300 Then
Me.T2 = Me.Chromium
Me.T2.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. .....
'Copper
If Me.ctr3 = 1 Then
Me.T3 = Me.Copper
Me.T3.Requery
Else
If Me.ctr3 = 2 Then
Me.T3 = Me.Copper * 1000
Me.T3.Requery
Else
If Me.ctr3 = 3 Then
Me.T3 = Me.Copper / 1000
Me.T3.Requery
Else
If Me.ctr3 = 10 Then
Me.T3 = Me.Copper / 1000
Me.T3.Requery
Else
If Me.ctr3 = 20 Then
Me.T3 = Me.Copper
Me.T3.Requery
Else
If Me.ctr3 = 30 Then
Me.T3 = Me.Copper / 1000000
Me.T3.Requery
Else
If Me.ctr3 = 100 Then
Me.T3 = Me.Copper * 1000
Me.T3.Requery
Else
If Me.ctr3 = 200 Then
Me.T3 = Me.Copper * 1000000
Me.T3.Requery
Else
If Me.ctr3 = 300 Then
Me.T3 = Me.Copper
Me.T3.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ......
'Fluoride
If Me.ctr4 = 1 Then
Me.T4 = Me.Fluoride
Me.T4.Requery
Else
If Me.ctr4 = 2 Then
Me.T4 = Me.Fluoride * 1000
Me.T4.Requery
Else
If Me.ctr4 = 3 Then
Me.T4 = Me.Fluoride / 1000
Me.T4.Requery
Else
If Me.ctr4 = 10 Then
Me.T4 = Me.Fluoride / 1000
Me.T4.Requery
Else
If Me.ctr4 = 20 Then
Me.T4 = Me.Fluoride
Me.T4.Requery
Else
If Me.ctr4 = 30 Then
Me.T4 = Me.Fluoride / 1000000
Me.T4.Requery
Else
If Me.ctr4 = 100 Then
Me.T4 = Me.Fluoride * 1000
Me.T4.Requery
Else
If Me.ctr4 = 200 Then
Me.T4 = Me.Fluoride * 1000000
Me.T4.Requery
Else
If Me.ctr4 = 300 Then
Me.T4 = Me.Fluoride
Me.T4.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ........
'Iodine
If Me.ctr5 = 1 Then
Me.T4 = Me.Iodine
Me.T4.Requery
Else
If Me.ctr5 = 2 Then
Me.T5 = Me.Iodine * 1000
Me.T5.Requery
Else
If Me.ctr5 = 3 Then
Me.T5 = Me.Iodine / 1000
Me.T5.Requery
Else
If Me.ctr5 = 10 Then
Me.T5 = Me.Iodine / 1000
Me.T5.Requery
Else
If Me.ctr5 = 20 Then
Me.T5 = Me.Iodine
Me.T5.Requery
Else
If Me.ctr5 = 30 Then
Me.T5 = Me.Iodine / 1000000
Me.T5.Requery
Else
If Me.ctr5 = 100 Then
Me.T5 = Me.Iodine * 1000
Me.T5.Requery
Else
If Me.ctr5 = 200 Then
Me.T5 = Me.Iodine * 1000000
Me.T5.Requery
Else
If Me.ctr5 = 300 Then
Me.T5 = Me.Iodine
Me.T5.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. .........
'Iron
If Me.ctr6 = 1 Then
Me.T6 = Me.Iron
Me.T6.Requery
Else
If Me.ctr6 = 2 Then
Me.T6 = Me.Iron * 1000
Me.T6.Requery
Else
If Me.ctr6 = 3 Then
Me.T6 = Me.Iron / 1000
Me.T6.Requery
Else
If Me.ctr6 = 10 Then
Me.T6 = Me.Iron / 1000
Me.T6.Requery
Else
If Me.ctr6 = 20 Then
Me.T6 = Me.Iron
Me.T6.Requery
Else
If Me.ctr6 = 30 Then
Me.T6 = Me.Iron / 1000000
Me.T6.Requery
Else
If Me.ctr6 = 100 Then
Me.T6 = Me.Iron * 1000
Me.T6.Requery
Else
If Me.ctr6 = 200 Then
Me.T6 = Me.Iron * 1000000
Me.T6.Requery
Else
If Me.ctr6 = 300 Then
Me.T6 = Me.Iron
Me.T6.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ..............
'Magnesium
If Me.ctr7 = 1 Then
Me.T7 = Me.Magnesium
Me.T7.Requery
Else
If Me.ctr7 = 2 Then
Me.T7 = Me.Magnesium * 1000
Me.T7.Requery
Else
If Me.ctr7 = 3 Then
Me.T7 = Me.Magnesium / 1000
Me.T7.Requery
Else
If Me.ctr7 = 10 Then
Me.T7 = Me.Magnesium / 1000
Me.T7.Requery
Else
If Me.ctr7 = 20 Then
Me.T7 = Me.Magnesium
Me.T7.Requery
Else
If Me.ctr7 = 30 Then
Me.T7 = Me.Magnesium / 1000000
Me.T7.Requery
Else
If Me.ctr7 = 100 Then
Me.T7 = Me.Magnesium * 1000
Me.T7.Requery
Else
If Me.ctr7 = 200 Then
Me.T7 = Me.Magnesium * 1000000
Me.T7.Requery
Else
If Me.ctr7 = 300 Then
Me.T7 = Me.Magnesium
Me.T7.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ..............
'Manganese
If Me.ctr8 = 1 Then
Me.T8 = Me.Manganese
Me.T8.Requery
Else
If Me.ctr8 = 2 Then
Me.T8 = Me.Manganese * 1000
Me.T8.Requery
Else
If Me.ctr8 = 3 Then
Me.T8 = Me.Manganese / 1000
Me.T8.Requery
Else
If Me.ctr8 = 10 Then
Me.T8 = Me.Manganese / 1000
Me.T8.Requery
Else
If Me.ctr8 = 20 Then
Me.T8 = Me.Manganese
Me.T8.Requery
Else
If Me.ctr8 = 30 Then
Me.T8 = Me.Manganese / 1000000
Me.T8.Requery
Else
If Me.ctr8 = 100 Then
Me.T8 = Me.Manganese * 1000
Me.T8.Requery
Else
If Me.ctr8 = 200 Then
Me.T8 = Me.Manganese * 1000000
Me.T8.Requery
Else
If Me.ctr8 = 300 Then
Me.T8 = Me.Manganese
Me.T8.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. .......
'Molybdenum
If Me.ctr9 = 1 Then
Me.T9 = Me.Molybdenum
Me.T9.Requery
Else
If Me.ctr9 = 2 Then
Me.T9 = Me.Molybdenum * 1000
Me.T9.Requery
Else
If Me.ctr9 = 3 Then
Me.T9 = Me.Molybdenum / 1000
Me.T9.Requery
Else
If Me.ctr9 = 10 Then
Me.T9 = Me.Molybdenum / 1000
Me.T9.Requery
Else
If Me.ctr9 = 20 Then
Me.T9 = Me.Molybdenum
Me.T9.Requery
Else
If Me.ctr9 = 30 Then
Me.T9 = Me.Molybdenum / 1000000
Me.T9.Requery
Else
If Me.ctr9 = 100 Then
Me.T9 = Me.Molybdenum * 1000
Me.T9.Requery
Else
If Me.ctr9 = 200 Then
Me.T9 = Me.Molybdenum * 1000000
Me.T9.Requery
Else
If Me.ctr9 = 300 Then
Me.T9 = Me.Molybdenum
Me.T9.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ........
'Phosphorus
If Me.ctr10 = 1 Then
Me.T10 = Me.Phosphorus
Me.T10.Requery
Else
If Me.ctr10 = 2 Then
Me.T10 = Me.Phosphorus * 1000
Me.T10.Requery
Else
If Me.ctr10 = 3 Then
Me.T10 = Me.Phosphorus / 1000
Me.T10.Requery
Else
If Me.ctr10 = 10 Then
Me.T10 = Me.Phosphorus / 1000
Me.T10.Requery
Else
If Me.ctr10 = 20 Then
Me.T10 = Me.Phosphorus
Me.T10.Requery
Else
If Me.ctr10 = 30 Then
Me.T10 = Me.Phosphorus / 1000000
Me.T10.Requery
Else
If Me.ctr10 = 100 Then
Me.T10 = Me.Phosphorus * 1000
Me.T10.Requery
Else
If Me.ctr10 = 200 Then
Me.T10 = Me.Phosphorus * 1000000
Me.T10.Requery
Else
If Me.ctr10 = 300 Then
Me.T10 = Me.Phosphorus
Me.T10.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ........
'Selenium
If Me.ctr11 = 1 Then
Me.T11 = Me.Selenium
Me.T11.Requery
Else
If Me.ctr11 = 2 Then
Me.T11 = Me.Selenium * 1000
Me.T11.Requery
Else
If Me.ctr11 = 3 Then
Me.T11 = Me.Selenium / 1000
Me.T11.Requery
Else
If Me.ctr11 = 10 Then
Me.T11 = Me.Selenium / 1000
Me.T11.Requery
Else
If Me.ctr11 = 20 Then
Me.T11 = Me.Selenium
Me.T11.Requery
Else
If Me.ctr11 = 30 Then
Me.T11 = Me.Selenium / 1000000
Me.T11.Requery
Else
If Me.ctr11 = 100 Then
Me.T11 = Me.Selenium * 1000
Me.T11.Requery
Else
If Me.ctr11 = 200 Then
Me.T11 = Me.Selenium * 1000000
Me.T11.Requery
Else
If Me.ctr11 = 300 Then
Me.T11 = Me.Selenium
Me.T11.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ........
'Zinc
If Me.ctr12 = 1 Then
Me.T12 = Me.Zinc
Me.T12.Requery
Else
If Me.ctr12 = 2 Then
Me.T12 = Me.Zinc * 1000
Me.T12.Requery
Else
If Me.ctr12 = 3 Then
Me.T12 = Me.Zinc / 1000
Me.T12.Requery
Else
If Me.ctr12 = 10 Then
Me.T12 = Me.Zinc / 1000
Me.T12.Requery
Else
If Me.ctr12 = 20 Then
Me.T12 = Me.Zinc
Me.T12.Requery
Else
If Me.ctr12 = 30 Then
Me.T12 = Me.Zinc / 1000000
Me.T12.Requery
Else
If Me.ctr12 = 100 Then
Me.T12 = Me.Zinc * 1000
Me.T12.Requery
Else
If Me.ctr12 = 200 Then
Me.T12 = Me.Zinc * 1000000
Me.T12.Requery
Else
If Me.ctr12 = 300 Then
Me.T12 = Me.Zinc
Me.T12.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ........
'Potassium
If Me.ctr13 = 1 Then
Me.T13 = Me.Potassium
Me.T13.Requery
Else
If Me.ctr13 = 2 Then
Me.T13 = Me.Potassium * 1000
Me.T13.Requery
Else
If Me.ctr13 = 3 Then
Me.T13 = Me.Potassium / 1000
Me.T13.Requery
Else
If Me.ctr13 = 10 Then
Me.T13 = Me.Potassium / 1000
Me.T13.Requery
Else
If Me.ctr13 = 20 Then
Me.T13 = Me.Potassium
Me.T13.Requery
Else
If Me.ctr13 = 30 Then
Me.T13 = Me.Potassium / 1000000
Me.T13.Requery
Else
If Me.ctr13 = 100 Then
Me.T13 = Me.Potassium * 1000
Me.T13.Requery
Else
If Me.ctr13 = 200 Then
Me.T13 = Me.Potassium * 1000000
Me.T13.Requery
Else
If Me.ctr13 = 300 Then
Me.T13 = Me.Potassium
Me.T13.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ........
'Sodium
If Me.ctr14 = 1 Then
Me.T14 = Me.Sodium
Me.T14.Requery
Else
If Me.ctr14 = 2 Then
Me.T14 = Me.Sodium * 1000
Me.T14.Requery
Else
If Me.ctr14 = 3 Then
Me.T14 = Me.Sodium / 1000
Me.T14.Requery
Else
If Me.ctr14 = 10 Then
Me.T14 = Me.Sodium / 1000
Me.T14.Requery
Else
If Me.ctr14 = 20 Then
Me.T14 = Me.Sodium
Me.T14.Requery
Else
If Me.ctr14 = 30 Then
Me.T14 = Me.Sodium / 1000000
Me.T14.Requery
Else
If Me.ctr14 = 100 Then
Me.T14 = Me.Sodium * 1000
Me.T14.Requery
Else
If Me.ctr14 = 200 Then
Me.T14 = Me.Sodium * 1000000
Me.T14.Requery
Else
If Me.ctr14 = 300 Then
Me.T14 = Me.Sodium
Me.T14.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
'................................................. ........
'Cloride
If Me.ctr15 = 1 Then
Me.T15 = Me.Cloride
Me.T15.Requery
Else
If Me.ctr15 = 2 Then
Me.T15 = Me.Cloride * 1000
Me.T15.Requery
Else
If Me.ctr15 = 3 Then
Me.T15 = Me.Cloride / 1000
Me.T15.Requery
Else
If Me.ctr15 = 10 Then
Me.T15 = Me.Cloride / 1000
Me.T15.Requery
Else
If Me.ctr15 = 20 Then
Me.T15 = Me.Cloride
Me.T15.Requery
Else
If Me.ctr15 = 30 Then
Me.T15 = Me.Cloride / 1000000
Me.T15.Requery
Else
If Me.ctr15 = 100 Then
Me.T15 = Me.Cloride * 1000
Me.T15.Requery
Else
If Me.ctr15 = 200 Then
Me.T15 = Me.Cloride * 1000000
Me.T15.Requery
Else
If Me.ctr15 = 300 Then
Me.T15 = Me.Cloride
Me.T15.Requery
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub