[AccessD] select more then one

Marcus, Scott (GEAE, Contractor) scott.marcus at ae.ge.com
Mon Jul 28 07:10:25 CDT 2003


Pedro,
 
We should really know the whole picture so that the code doesn't need to be
rewritten each time you give us a new piece of information. Anyway, this
should get you there (with some minor tweaks). Watch out for line wrapping
in the e-mail...
 
Dim strNumbers As String, strNumber As String
Dim intLoc As Integer, intNumber As Integer
Dim bolFound As Boolean
 
bolFound = False
For intNumber = 1 To 5 ' Build a string that represents each checked Product
Code
    If Me("chbProductCode" & intNumber) = True Then
        strNumbers = strNumbers & intNumber & ";"
        bolFound = True
    End If
Next intNumber
 
If bolFound = True Then
    strNumbers = Left(strNumbers, Len(strNumbers) - 1)
End If
 
While bolFound = True
    intLoc = InStr(strNumbers, ";")

    If intLoc > 0 Then ' see if the are more than one to deal with
        ' There are more than one so, parse out individual numbers
        strNumber = Left(strNumbers, intLoc - 1)
        strNumbers = Right(strNumbers, Len(strNumbers) - intLoc)
    Else
        ' This is the last one
        strNumber = strNumbers
        bolFound = False
    End If

    .Item("ProductCode" & strNumber).Value = Nz(Me("txtProductCode" & _
        strNumber))
    .Item("Number" & strNumber).Value = Nz(Me![txtNumber])
 
    'You need to change this for what you are doing
    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
Wend

 
Scott
 

-----Original Message-----
From: Pedro Janssen [mailto:pedro at plex.nl]
Sent: Saturday, July 26, 2003 10:22 AM
To: AccessD at databaseadvisors.com
Subject: [AccessD] select more then one


Hello Group,
 
with the code below i get as result: One  Produktcode,  One number and  One
price depending on which checkboxProduktcode is selected.
 
Is there a way to change this code so that i could select more then one
checkboxProduktcode (still only one of the chbA1, chbA2, chbA3 or
chbUitz1can be selected) and that the outcome would be the selected
produktcodes with there numbers and prices
 
TIA
 
Pedro Janssen
 
 
 
 
 
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
ElseIf chbProductCode3 = true then
    strNumber = "3"
    bolFound = True
ElseIf chbProductCode4 = true then
    strNumber = "4"
    bolFound = True
ElseIf chbProductCode5 = true then
    strNumber = "5"
    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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030728/6c84e0dc/attachment-0001.html>


More information about the AccessD mailing list