+ Reply to Thread
Results 1 to 3 of 3

Form with option button how change row involved??

Hybrid View

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    Milan
    MS-Off Ver
    Excel 2010
    Posts
    24

    Form with option button how change row involved??

    Dear all, please help me.
    I have a search frame with three option buttons, now i would change the row involved in the choice.
    I'm not very expert with VB, i tried to change the name (Opt1, Opt2, Opt3) but unfortunately it doesn't work.
    Please can you help me to try the code to modify?

    Thanks a lot!
    Salvatore

    '================================
    '===== Pulsanti frame Trova =====
    '================================
    
    Private Sub cmdIniziaRicerca_Click()
    
        Dim ctrl As Control
        Dim lCampo As Long
        Dim lRif As Long
        Dim c As Range
        Dim rng As Range
        Dim lUltRiga As Long
        
        lCampo = 0
        
        With Me
        
            
            With .frSelezionaCampo
            
                For Each ctrl In .Controls
                    If ctrl.Value = True Then
                        lCampo = Mid(ctrl.Name, _
                        4, Len(ctrl.Name))
                        
                    End If
                Next
            
            End With
            
            If .txtRicerca <> "" And lCampo <> 0 Then
            
                lUltRiga = sh.Range( _
                    "A" & Rows.Count).End(xlUp).Row
                Set rng = sh.Range("A2:I" & lUltRiga)
                
                For Each c In rng.Range( _
                    Cells(1, lCampo), _
                    Cells(lUltRiga, lCampo))
                    If c.Value = .txtRicerca.Text Then
                        lRif = 4 - lCampo
                        .txtID.Value = sh.Cells(c.Row, 1).Value
                       
                        .cboSheet.Value = sh.Cells(c.Row, 2).Value
                        .txtInvoice.Value = sh.Cells(c.Row, 3).Value
                        .cbomonth.Value = sh.Cells(c.Row, 4).Value
                        
                        .TxtDatum.Value = sh.Cells(c.Row, 5).Value
                        .TxtCause.Value = sh.Cells(c.Row, 6).Value
                        .TxtAmount.Value = sh.Cells(c.Row, 7).Value
                        .cbotype.Value = sh.Cells(c.Row, 8).Value
                        .cbodebtor.Value = sh.Cells(c.Row, 9).Value
                         .TxtNote.Value = sh.Cells(c.Row, 10).Value
                        
                        
                        lRigaAttiva = c.Row
                        lRigaValoreTrovato = c.Row
                        Exit For
                    End If
                Next
            Else
                MsgBox "Nessun dato inserito o nessun campo di ricerca selezionato.", _
                    vbOKOnly, "Attenzione"
            End If
            
        End With
        
        Set ctrl = Nothing
        Set c = Nothing
        Set rng = Nothing
        
    End Sub
    Attached Files Attached Files
    Last edited by Leith Ross; 07-09-2013 at 05:21 PM. Reason: Added Code Tags

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Form with option button how change row involved??

    Do you mean resetting the optionbuttons?
            Else
                MsgBox "Nessun dato inserito o nessun campo di ricerca selezionato.", _
                    vbOKOnly, "Attenzione"
            End If
            
            With .frSelezionaCampo
            
                For Each Ctrl In .Controls
                    If TypeName(Ctrl) = "OptionButton" Then
                        Ctrl = False
                    End If
                Next
                
            End With
        .txtRicerca = ""
        End With
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    07-03-2013
    Location
    Milan
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Form with option button how change row involved??

    Solved, thank you very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1