reduce code

bodylojohn

Registered User.
Local time
Today, 14:21
Joined
Dec 28, 2005
Messages
205
Hello,

I have this code. But I guess that I can make it a lot shorter.

Can anybody help me?

Public Sub ExtraVeldenMedewerkerDetails()


Code:
strExtraTekstVeld01 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 1")
strExtraTekstVeld02 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 2")
strExtraTekstVeld03 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 3")
strExtraTekstVeld04 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 4")
strExtraTekstVeld05 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 5")
  
strExtraDatumVeld01 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 6")
strExtraDatumVeld02 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 7")
strExtraDatumVeld03 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 8")
strExtraDatumVeld04 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 9")
strExtraDatumVeld05 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 10")
  
strExtraJaNee01 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 11")
strExtraJaNee02 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 12")
strExtraJaNee03 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 13")
strExtraJaNee04 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 14")
strExtraJaNee05 = DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 15")

End Sub

Code:
lblExtraTekstVeld01.Caption = strExtraTekstVeld01 & ":"
lblExtraTekstVeld02.Caption = strExtraTekstVeld02 & ":"
lblExtraTekstVeld03.Caption = strExtraTekstVeld03 & ":"
lblExtraTekstVeld04.Caption = strExtraTekstVeld04 & ":"
lblExtraTekstVeld05.Caption = strExtraTekstVeld05 & ":"

lblExtraDatumVeld01.Caption = strExtraDatumVeld01 & ":"
lblExtraDatumVeld02.Caption = strExtraDatumVeld02 & ":"
lblExtraDatumVeld03.Caption = strExtraDatumVeld03 & ":"
lblExtraDatumVeld04.Caption = strExtraDatumVeld04 & ":"
lblExtraDatumVeld05.Caption = strExtraDatumVeld05 & ":"

lblExtraJaNee01.Caption = strExtraJaNee01 & ":"
lblExtraJaNee02.Caption = strExtraJaNee02 & ":"
lblExtraJaNee03.Caption = strExtraJaNee03 & ":"
lblExtraJaNee04.Caption = strExtraJaNee04 & ":"
lblExtraJaNee05.Caption = strExtraJaNee05 & ":"
 
Try the below code in the forms class module

Code:
    Dim myRec As DAO.Recordset
    Dim sSQL As String
    
    DLookup("LabelWaarde", "tblBEHEER_VRIJVELD_MEDEWERKER", "[VrijVeld_ID]= 11")
    sSQL = "Select tblBEHEER_VRIJVELD_MEDEWERKER.* FROM tblBEHEER_VRIJVELD_MEDEWERKER Where VrijVeld_ID<=15 ORDER BY VrijVeld_ID"
    
    Set myRec = CurrentDb.OpenRecordset(sSQL)
    myRec.MoveFirst
    
    lblExtraTekstVeld01.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraTekstVeld02.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraTekstVeld03.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraTekstVeld04.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraTekstVeld05.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraDatumVeld01.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraDatumVeld02.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraDatumVeld03.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraDatumVeld04.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraDatumVeld05.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraJaNee01.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraJaNee02.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraJaNee03.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraJaNee04.Caption = myRec.Fields("LabelWaarde") & ":"
    myRec.MoveNext
    lblExtraJaNee05.Caption = myRec.Fields("LabelWaarde") & ":"
        
    myRec.Close
    Set myRec = Nothing
 

Users who are viewing this thread

Back
Top Bottom