[AccessD] select more then one

Jim DeMarco Jdemarco at hshhp.org
Fri Aug 1 07:08:13 CDT 2003


How about something like this:
<code>
Function ShowHide(ctl as Control)
Dim inner As Integer
Dim outer as Integer
Dim ShowIndex As Integer
ShowIndex = Right(ctl.Name, 1)
For  outer = 1 To 5
  For i = 1 To 26
      If outer = Cint(ShowIndex) Then
        Controls("Field" & ShowIndex & "_" & CStr(i)).Visible = True
      Else
        Controls("Field" & outer & "_" & CStr(i)).Visible = False
      End If
      'or
        Controls("Field" & outer & "_" & CStr(i)).Visible = (outer = Cint(ShowIndex))
  Next inner
Next outer
 
End Function
</code>
 
or use this simplified version to replace the If block:
 
<snip>
        Controls("Field" & outer & "_" & CStr(i)).Visible = (outer = Cint(ShowIndex))
</snip>
 
Assuming chbProductcode1 through 5 are controls call this function from each of the (chbProductcode1) click or change event passing in the name of the calling control:
 
<usage>
Sub chbProductcode1_Click()
  ShowHide(chbProductcode1)
End Sub
</usage>

HTH, 

Jim DeMarco 
Director of Product Development 
HealthSource/Hudson Health Plan 

-----Original Message-----
From: Pedro Janssen [mailto:pedro at plex.nl]
Sent: Thursday, July 31, 2003 5:16 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] select more then one


Hello Scott an the rest of the group
 
i have one more question, if you don't mind. Its not that i didn't wanted to give you the whole picture, i wanted to solve this problem myself in the code you suggested (for learning reasons), but i didn't solve it. It was to difficult for me.
 
I would like that:
when chbProductcode1 = true, fields 1_1 until fields 1_26 are visible, when chbProductcode1 = false, fields 1_1 until fields 1_26 are not visible. when chbProductcode2 = true, fields 2_1 until fields 2_26 are visible, when chbProductcode2 = false, fields 2_1 until fields 2_26 are not visible.
when chbProductcode3 = true, fields 3_1 until fields 3_26 are visible, when chbProductcode3 = false, fields 3_1 until fields 3_26 are not visible
etc for 4 and 5
 
TIA
 
Pedro Janssen
 
 
 
----- Original Message ----- 

From: Marcus,  <mailto:scott.marcus at ae.ge.com> Scott (GEAE, Contractor) 
To: 'Access Developers discussion and  <mailto:accessd at databaseadvisors.com> problem solving' 
Sent: Monday, July 28, 2003 2:10 PM
Subject: RE: [AccessD] select more then one

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




  _____  




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




***********************************************************************************
"This electronic message is intended to be for the use only of the named recipient, and may contain information from Hudson Health Plan (HHP) that is confidential or privileged.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited.  If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message.  Thank You".
***********************************************************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030801/93c3c80c/attachment-0001.html>


More information about the AccessD mailing list