Results 1 to 7 of 7
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    find value in table (6.0)

    In a mdb in table USER_NAME have a fileds AGENCY and filed USER
    Now, is possible to find the value inserted in text1 and if existis correspondence with AGENCY and USER (in label3) continue the macro code in other case show msgbox NOT PRESENT IN THIS GROUP & ", exit sub close userform

    Example user ok:
    Assuming the var USER_LOG = OI15535 this user have correspondence for 4500 filed AGENCY
    in this case existis a correspondence, go to the next line of code.....ecc...

    Example user no ok:
    Assuming the var USER_LOG = OI15535 this user is not have correspondence for 4561 filed AGENCY
    in this case not existis a correspondence, go to msgbox, exit sub, ecc...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find value in table (6.0)

    Does this do what you want?
    <code>
    Private Sub SELECT_Click()
    Dim CN As New ADODB.Connection
    Dim RS As New ADODB.Recordset
    Dim f As Boolean

    On Error GoTo Err_Sub

    CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    "C:TEST_MDBSTORICO_INPS.MDB;Persist Security Info=False"
    RS.Open "SELECT * FROM USER_NAME", CN, adOpenStatic, adLockReadOnly
    RS.Find "MATRICOLA = '" & USER_LOG & "'"
    If RS.EOF Or RS.BOF Then
    MsgBox "Nessun record corrente", vbCritical
    GoTo Exit_Sub
    End If

    If Me.Text1.Text = "" Then
    MsgBox "INSERIRE CODICE AGENZIA!", vbCritical
    Me.Text1.SetFocus
    GoTo Exit_Sub
    End If

    If Not RS!AGENZIA = Me.Text1.Text Then
    MsgBox "UTENTE NON PRESENTE IN AGENZIA!", vbCritical
    f = True
    GoTo Exit_Sub
    End If

    ' other code goes here

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find value in table (6.0)

    Sorry me Hans... but my english not id good, as usual.

    i have modified code in click event...
    in effect only if existis a joined from (Me.Text1.Text value) and (USER_LOG) go to next line of code, and if not existis correspondence of this joined data exit sub, msgbox, ecc...

    see now:

    Private Sub SELECT_Click()
    Dim CN As New ADODB.Connection
    Dim RS As New ADODB.Recordset
    Dim F As Boolean
    Dim AGENZIA As String

    If Me.Text1.Text = "" Then
    MsgBox "INSERIRE CODICE AGENZIA!", vbCritical
    Me.Text1.SetFocus
    GoTo Exit_Sub
    End If

    AGENZIA = Me.Text1.Text

    On Error GoTo Err_Sub

    CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    "C:TEST_MDBSTORICO_INPS.MDB;Persist Security Info=False"
    RS.Open "SELECT * FROM USER_NAME", CN, adOpenStatic, adLockReadOnly

    'here controll if existis AGENZIA & USER_LOG
    'similar RS.Find "AGENZIA&MATRICOLA

    If RS.EOF Or RS.BOF Then
    MsgBox "Nessun record corrente with AGENZIA+USER_LOG", vbCritical
    GoTo Exit_Sub
    End If

    If Not AGENZIA&MATRICOLA Then ' in recordset
    MsgBox "UTENTE NON PRESENTE IN AGENZIA!", vbCritical
    F = True
    GoTo Exit_Sub
    End If





    'MODIFICHE_USER.ENTER_PROVA1 = Text1.Text
    'MODIFICHE_USER.Show
    'Unload Me

    Exit_Sub:
    On Error Resume Next
    RS.Close
    Set RS = Nothing
    CN.Close
    Set CN = Nothing
    If F = True Then
    Unload Me
    End If
    Exit Sub

    Err_Sub:
    MsgBox Err.Description, vbCritical
    Resume Exit_Sub

    End Sub

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find value in table (6.0)

    Try the attached code.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find value in table (6.0)

    perfect!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

    Only....
    i have fonud a little distraction...

    you piece of code:
    USER_LOG & "' AND AGENZIA = '" & Me.Text1 .Txt & "'", CN, adOpenStatic, _

    here "e" Text

    your student<img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find value in table (6.0)

    > here "e" Text

    That's because I cannot test the real code <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  7. #7
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find value in table (6.0)

    i know you dont have VB installed on pc but sure you have installed a new program BIGMIND ver. 100000000000000000000000000000.1
    <img src=/S/smile.gif border=0 alt=smile width=15 height=15> <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

Posting Permissions

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