Results 1 to 3 of 3
  1. #1
    Juliano is offline Novice
    Windows 98/ME Access 2007
    Join Date
    Nov 2010
    Posts
    1

    Simple Search form

    Hi forum,



    I need tips or file with examples about 'how to make a search form in access' where:

    - When the user typing the code number in 'code' field (key field), show the others data in the fields. (Add:, Satate:, date:, ...)
    - otherwise, if the register with the code number is 'not found' then keep the blank fields to add new register.

    thanks a lot

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    This is what I have done:

    I have a form with recordsource table tblEmp.
    I have a text box where user can type EmpID and click on a search button will filter the record and display it. If now record is not found a msgbox is displayed and a new record opens for data entry. To remove filter click remove filter button. The code attached to the Filter button is as follows:

    Private Sub Command10_Click()
    On Error GoTo Err_Command10_Click
    Dim intRecordCount As String
    intRecordCount = IIf(IsNull(DCount("[EmpID]", "tblEmp", "[EmpID]=" & Me.Text8)), 0, DCount("[EmpID]", "tblEmp", "[EmpID]=" & Me.Text8))

    If intRecordCount = 0 Then
    MsgBox "No Record For this ID"
    DoCmd.GoToRecord , , acNewRec
    Me.Command16.Enabled = False
    Else
    Me.Filter = "EmpID=" & Me.Text8
    Me.FilterOn = True
    Me.Command16.Enabled = True
    End If
    Exit_Command10_Click:
    Exit Sub

    Err_Command10_Click:
    MsgBox Err.Description
    Resume Exit_Command10_Click

    End Sub
    employee ID is available from 1 to 3 type any other number (> 3) a new record opens after a msg prompt


    Refer to attached mdb file.
    Last edited by maximus; 11-24-2010 at 06:53 AM.

  3. #3
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682

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

Similar Threads

  1. simple form problem
    By kcsun in forum Forms
    Replies: 0
    Last Post: 08-12-2010, 12:28 AM
  2. Simple list/combo search fails
    By Dega in forum Forms
    Replies: 4
    Last Post: 02-08-2010, 08:39 AM
  3. Save and Go to another form - simple yes?
    By durstlaw in forum Forms
    Replies: 1
    Last Post: 12-15-2009, 12:46 AM
  4. Lookup Form (should be simple)
    By joshlee in forum Forms
    Replies: 3
    Last Post: 05-06-2009, 12:04 PM
  5. Simple Nav Form Code Not Working
    By alsoto in forum Forms
    Replies: 10
    Last Post: 04-10-2009, 09:30 AM

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