[AccessD] shorter and quicker code

tsm at zoomtown.com tsm at zoomtown.com
Fri Jul 18 17:49:58 CDT 2003


Pedro,

I was working off the top of my head and forgot some stupid stuff so I fixed it. Also, this may be faster to write but it will run slower.

Dim strNumber as String
Dim bolFound as Boolean

bolFound = False
If chbProductCode1 = true then
    strNumber = "1"
    bolFound = True
ElseIf chbProductCode2 = true then
    strNumber = "2"
    bolFound = True
EndIf

If bolFound = True then
    .Item("ProductCode" & strNumber).Value = Nz(Me("txtProductCode" & _
        strNumber))
    .Item("Number" & strNumber).Value = Nz(Me![txtNumber])
    
    If chbA1 = True then
        .Item("Price" & strNumber).Value = Nz(Me("txt" & _
            strNumber & "c16"))
    ElseIf chbA2 = True then
        .Item("Price" & strNumber).Value = Nz(Me("txt" & _
            strNumber & "c17"))
    ElseIf chbA3 = True then
        .Item("Price" & strNumber).Value = Nz(Me("txt" & _
            strNumber & "c18"))
    ElseIf chbUitz1 = True then
        .Item("Number" & strNumber).Value = Nz(Me("txtUitz" & _
            strNumber & "Number"))
        .Item("Price" & strNumber).Value = Nz(Me("txtUitz" & _
            strNumber & "Price"))
    End If
End If

Scott

 

From: <tsm at zoomtown.com>
Date: 2003/07/18 Fri PM 06:38:12 EDT
To: Access Developers discussion and problem solving
	<accessd at databaseadvisors.com>
Subject: Re: [AccessD] shorter and quicker code

Pedro,

Try the following:

Dim strNumber as String
Dim bolFound as Boolean

bolFound = False
If chbProductCode1 = true then
    strNumber = 1
    bolFound = True
ElseIf chbProductCode2 = true then
    strNumber = 2
    bolFound = True
EndIf

If bolFound = True then
    .Item("ProductCode" & strNumber).Value = Nz(Me![txtProductCode1])
    .Item("Number" & strNumber).Value = Nz(Me![txtNumber])
    
    If chbA1 = True then
       .Item("Price" & strNumber).Value = Nz(Me("txt" & _
           strNumber & "c16"))
    ElseIf chbA2 = True then
        .Item("Price" & strNumber).Value = Nz(Me("txt" & _
           strNumber & "c17"))
    ElseIf chbA3 = True then
        .Item("Price" & strNumber).Value = Nz(Me("txt" & _
           strNumber & "c18"))
    ElseIf chbUitz1 = True then
        .Item("Number" & strNumber).Value = Nz(Me("txtUitz" & _
            strNumber & "Number"))
        .Item("Price" & strNumber).Value = Nz(Me("txtUitz" & _
            strNumber & "Price"))
    End If
End If

Scott

From: "Pedro Janssen" <pedro at plex.nl>
Date: 2003/07/18 Fri PM 05:31:35 EDT
To: <AccessD at databaseadvisors.com>
Subject: [AccessD] shorter and quicker code

Hello Group,

the code below is part of a code that i have to write in about five versions for 10 ProductCode's.
This is a lot of typing, copying, pasting and you can't let your mind slip away, otherwise you make mistakes. Is there a shorter and quicker way?

TIA

Pedro Janssen


If chbProductCode1= True then
    .Item("ProductCode1").Value = Nz(Me![txtProductCode1])
    
    If chbA1 = True then
       .Item("Number1").Value = Nz(Me![txtNumber])
       .Item("Price1").Value = Nz(Me![txt1c16])
    ElseIf chbA2 = True then
        .Item("Number1").Value = Nz(Me![txtNumber])
        .Item("Price1").Value = Nz(Me![txt1c17])
    ElseIf chbA3 = True then
        .Item("Number1").Value = Nz(Me![txtNumber])
        .Item("Price1").Value = Nz(Me![txt1c18])
    ElseIf chbUitz1 = True then
        .Item("Number1").Value = Nz(Me![txtUitz1Number])
        .Item("Price1").Value = Nz(Me![txtUitz1Price])
    End If
End If
 
 
If chbProductCode2= True then
    .Item("ProductCode2").Value = Nz(Me![txtProductCode2])
    
    If chbA1 = True then
       .Item("Number2").Value = Nz(Me![txtNumber])
       .Item("Price2").Value = Nz(Me![txt2c16])
    ElseIf chbA2 = True then
        .Item("Number2").Value = Nz(Me![txtNumber])
        .Item("Price2").Value = Nz(Me![txt2c17])
    ElseIf chbA3 = True then
        .Item("Number2").Value = Nz(Me![txtNumber])
        .Item("Price2").Value = Nz(Me![txt2c18])
    ElseIf chbUitz2 = True then
        .Item("Number2").Value = Nz(Me![txtUitz2Number])
        .Item("Price2").Value = Nz(Me![txtUitz2Price])
    End If
End If






_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030718/126fff99/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: reply
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030718/126fff99/attachment-0001.pl>


More information about the AccessD mailing list