Results 1 to 4 of 4
  1. #1
    ctathrh is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2022
    Posts
    7

    Search box

    Hi,

    I want to create a search box. I wanted the search box as in combo box and as I selected the value in the combo box, I want the form from the selected value to pop up.

    This is the code I use for my combo box but the record did not appear.

    Private Sub Combo8_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object


    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Type_Damage] = " & Str(Nz(Me![Combo8], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub

    Do anyone know is this code is correct or not

    I really new to access, hope anyone can teach me the steps to create it.



    Thank you

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    It should be possible to create this functionality by using the wizard to create the combo box.
    If you can't figure it out, post a copy of your db.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,943
    Firstly, how can a combo be null?
    Secondly test for NoMatch after a find.
    I am assuming you are using a combo as I do, first column autonumber,second description?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    this code is not right

    rs.FindFirst "[Type_Damage] = " & Str(Nz(Me![Combo8], 0))

    all depends on what datatype Type Damage is - if it is a string, why pass a 0? and the code would need to be

    rs.FindFirst "[Type_Damage] = '" & Str(Nz(Me![Combo8], 0)) & "'"

    if a number, you don't need to convert to a string

    rs.FindFirst "[Type_Damage] = " & Nz(Me![Combo8], 0)

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

Similar Threads

  1. Replies: 7
    Last Post: 01-15-2022, 01:18 AM
  2. Replies: 3
    Last Post: 08-21-2018, 03:11 PM
  3. Replies: 3
    Last Post: 09-12-2016, 11:49 AM
  4. Replies: 1
    Last Post: 03-26-2015, 11:08 AM
  5. Replies: 3
    Last Post: 09-02-2013, 04:33 PM

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