Results 1 to 3 of 3
  1. #1
    akhmadahdiyat is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Oct 2013
    Posts
    21

    .FindFirst problem

    i have code problem with .findfirst
    any help would be appreciate

    Code:
    sub CmdUbah_click()
            Dim RstUbah As Recordset
            Set RstUbah = CurrentDb.OpenRecordset("Set-User")
            With RstUbah
                MsgBox TextUserID.Value   '=== asoy
                MsgBox "[Login] = '*" & TextUserID.Value & "*'"     '=== [Login] = '*asoy*'
                .FindFirst "[Login] = '*" & TextUserID.Value & "*'"     ' ERROR at here#############
                If .NoMatch Then
                    'boleh ubah, lanjut cek nama
                    .FindFirst "[Nama] = '*" & TextNamaLengkap.Value & "*'"
                    If .NoMatch Then
                        .FindFirst "UID = edUserID"
                        .Edit
                        ![Login] = TextUserID.Value
                        ![Nama] = TextNamaLengkap.Value
                        ![Password] = TextPassword.Value
                        ![Grup] = TextGrupUser.Value
                        ![Keterangan] = TextKeterangan.Value
                        ![Pertanyaan] = TextPertanyaan.Value
                        ![Jawaban] = TextJawaban.Value
                        .Update
                        .Bookmark = .LastModified
                    Else
                        If !UID = TextUserID Then
                            .FindFirst "UID = edUserID"
                            .Edit
                            ![Login] = TextUserID.Value
                            ![Nama] = TextNamaLengkap.Value
                            ![Password] = TextPassword.Value
                            ![Grup] = TextGrupUser.Value
                            ![Keterangan] = TextKeterangan.Value
                            ![Pertanyaan] = TextPertanyaan.Value
                            ![Jawaban] = TextJawaban.Value
                            .Update
                            .Bookmark = .LastModified
                        Else
                            MsgBox "Nama ini sudah digunakan, harap memilih Nama yang lain"
                        End If
                    End If
                Else
                    If !UID = TextUserID Then
                        .FindFirst "[Nama] = '*" & TextNamaLengkap.Value & "*'"
                        If .NoMatch Then
                            .FindFirst "UID = edUserID"
                            .Edit
                            ![Login] = TextUserID.Value
                            ![Nama] = TextNamaLengkap.Value
                            ![Password] = TextPassword.Value
                            ![Grup] = TextGrupUser.Value
                            ![Keterangan] = TextKeterangan.Value
                            ![Pertanyaan] = TextPertanyaan.Value
                            ![Jawaban] = TextJawaban.Value
                            .Update
                            .Bookmark = .LastModified
                        Else
                            If !UID = TextUserID Then
                                .FindFirst "UID = edUserID"
                                .Edit
                                ![Login] = TextUserID.Value
                                ![Nama] = TextNamaLengkap.Value
                                ![Password] = TextPassword.Value
                                ![Grup] = TextGrupUser.Value
                                ![Keterangan] = TextKeterangan.Value
                                ![Pertanyaan] = TextPertanyaan.Value
                                ![Jawaban] = TextJawaban.Value
                                .Update
                                .Bookmark = .LastModified
                            Else
                                MsgBox "Nama ini sudah digunakan, harap memilih Nama yang lain"
                            End If
                        End If
                    Else
                        MsgBox "User ID ini sudah digunakan, harap memilih User ID yang lain"
                    End If
                End If
            .Close
            End With
            Set RstUbah = Nothing
            Reset
            CmdTambah.Visible = True
    end sub
    it said :
    error 3251
    operation not supported for this type of object

    I already change to :
    .FindFirst "[Login] = '*" & TextUserID.Value & "*'"
    .FindFirst "[Login] = *" & TextUserID.Value & "*"
    .FindFirst "[Login] = " & TextUserID.Value
    .FindFirst "[Login] = '" & TextUserID.Value & "'"
    .FindFirst "[Login] LIKE '*" & TextUserID.Value & "*'"
    .FindFirst "[Login] LIKE *" & TextUserID.Value & "*"
    .FindFirst "[Login] LIKE " & TextUserID.Value
    .FindFirst "[Login] LIKE '" & TextUserID.Value & "'"
    it says the same

    TextUserID, ... any Text prefix is a textbox with text data type
    UID is autonumber
    Set-User is a table with field: Login, Nama, Password, Grup, Keterangan, Pertanyaan, Jawaban



    where is is the wrong..

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I think this should be working for you.
    .FindFirst "[Login] Like '*" & TextUserID.Value & "*'"

    Why don't you try it without the wildcards first....
    .FindFirst "[Login] Like '" & TextUserID.Value & "'"
    This would require an exact match

  3. #3
    akhmadahdiyat is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Oct 2013
    Posts
    21
    sorry,, I figure it my self.. thank all..
    Code:
    Sub CmdUbah_Click()
        If CmdUbah.Caption = "Ubah" Then
            edUID = Me.UserCariSubForm!UID
            If Not (edUID = Error) Then
                edUserID = TextUserID.Value
                adNamaLengkap = TextNamaLengkap.Value
                adPassword = TextPassword.Value
                adGrup = TextGrup.Value
                adKeterangan = TextKeterangan.Value
                adPertanyaan = TextPertanyaan.Value
                adJawaban = TextJawaban.Value
                TextUserID.ControlSource = ""
                TextNamaLengkap.ControlSource = ""
                TextPassword.ControlSource = ""
                TextGrup.ControlSource = ""
                TextKeterangan.ControlSource = ""
                TextPertanyaan.ControlSource = ""
                TextJawaban.ControlSource = ""
                TextUserID.Value = edUserID
                TextNamaLengkap.Value = adNamaLengkap
                TextPassword.Value = adPassword
                TextGrup.Value = adGrup
                TextKeterangan.Value = adKeterangan
                TextPertanyaan.Value = adPertanyaan
                TextJawaban.Value = adJawaban
                CmdUbah.Caption = "Simpan"
                CmdHapus.Caption = "Batal"
                CmdTambah.Visible = False
            End If
        ElseIf CmdUbah.Caption = "Simpan" Then
            Dim RstUbah As Recordset
            Set RstUbah = CurrentDb.OpenRecordset("Set-User", dbOpenDynaset)
            With RstUbah
                .FindFirst "[Login] = '" & TextUserID.Value & "'"
                If .NoMatch Then
                    .FindFirst "[Nama] = '" & TextNamaLengkap.Value & "'"
                    If .NoMatch Then
                        UbahNama
                    Else
                        If !UID = TextUserID Then
                            UbahNama
                        Else
                            MsgBox "Nama ini sudah digunakan, harap memilih Nama yang lain1"
                        End If
                    End If
                Else
                    If !UID = edUID Then
                        .FindFirst "[Nama] = '" & TextNamaLengkap.Value & "'"
                        If .NoMatch Then
                            UbahNama
                        Else
                            If !UID = TextUserID Then
                                UbahNama
                            Else
                                MsgBox "Nama ini sudah digunakan, harap memilih Nama yang lain2"
                            End If
                        End If
                    Else
                        MsgBox "User ID ini sudah digunakan, harap memilih User ID yang lain3"
                    End If
                End If
            .Close
            End With
            Set RstUbah = Nothing
            Reset
        End If
    End Sub
    correction is Set RstUbah = CurrentDb.OpenRecordset("Set-User", dbOpenDynaset)

    Code:
    Sub UbahNama()
        Dim RstEdit As Recordset
        Set RstEdit = CurrentDb.OpenRecordset("Set-User", dbOpenDynaset)
        With RstEdit
            .FindFirst "UID = " & edUID
            .Edit
            ![Login] = TextUserID.Value
            ![Nama] = TextNamaLengkap.Value
            ![Password] = TextPassword.Value
            ![Grup] = TextGrup.Value
            ![Keterangan] = TextKeterangan.Value
            ![Pertanyaan] = TextPertanyaan.Value
            ![Jawaban] = TextJawaban.Value
            varUbah = MsgBox("Simpan pengaturan user ini", 68, "Informasi")
            If varUbah = 6 Then
                .Update
                'MsgBox "Tersimpan"
                CmdTambah.Visible = True
                CmdUbah.Caption = "Ubah"
            End If
            .Close
        End With
        Set RstEdit = Nothing
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Findfirst syntax problem
    By tarenja in forum Programming
    Replies: 2
    Last Post: 08-08-2013, 05:30 AM
  2. FINDFIRST Multiple criteria
    By trigirl67 in forum Forms
    Replies: 1
    Last Post: 01-31-2012, 02:02 PM
  3. Using FindFirst code
    By saltydawg617 in forum Access
    Replies: 2
    Last Post: 07-29-2011, 05:21 PM
  4. RST Findfirst date problem
    By ColPat in forum Programming
    Replies: 3
    Last Post: 08-09-2010, 07:28 AM
  5. Recordset Findfirst Problem
    By ColPat in forum Programming
    Replies: 6
    Last Post: 07-22-2010, 04:34 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums