Results 1 to 8 of 8
  1. #1
    Chekotah is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2014
    Posts
    32

    searching for records based off of one field from a table.


    I have a database that I am creating for my work. I have a form that I am trying to get it to search the information from a table to pull the record on the form. I would like to search infomation such as employee id and wanting it to pull that information from the table.

  2. #2
    Chekotah is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2014
    Posts
    32
    Ok i have fix this issue by creating ia unbound combo box. however now i need it to pull to a blank record so i can add a new record. any suggestions.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I think the following will do the trick

    DoCmd.GoToRecord , , 5

    Where the index 5 represents the constant acNewRec
    http://msdn.microsoft.com/en-us/libr...ffice.15).aspx
    Last edited by ItsMe; 03-19-2014 at 02:08 PM.

  4. #4
    Chekotah is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2014
    Posts
    32
    Thank you for responding and for you help. However I am still a bit confused.
    Here is the code that is currently on the db. However, I am not sure where to change the information to for it to pull a blank form when opening the form. I also need it so it will allow me to search the employee ID field for the records already in the form as well as create a new one when a new employee comes on board. I currently have this combo box attached to the Employee ID field and it will pull the appropriate information pertaining to that employee ID.
    Private Sub Combo86_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Employee ID] = " & Str(Nz(Me![Combo86], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub
    Private Sub Add_Record_Click()
    On Error GoTo Err_Add_Record_Click
    DoCmd.GoToRecord , , acNewRec
    Exit_Add_Record_Click:
    Exit Sub
    Err_Add_Record_Click:
    MsgBox Err.Description
    Resume Exit_Add_Record_Click

    End Sub

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The code you posted looks good. Is it not working for you?

    You can place the following in the form's load event
    DoCmd.GoToRecord , , acNewRec

    And it will open to a new record. Is this what you mean by "Blank"? A record will not be created/saved until after some data is typed into a bound control and said control loses focus.

    DoCmd.GoToRecord , , acNewRec
    is the same as
    DoCmd.GoToRecord , , 5

    I think it needs two commas. My original code I posted only has one. I am going to edit it now.

  6. #6
    Chekotah is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2014
    Posts
    32
    Thank you now i have a blank screen other than the employee ID field which is were the combo box is located. is there a way to for that not to show up.

    I appreciate all you help.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You can use the property sheet to set the property for your control. Setting the Visible property to No will hide the control from the user. You can do this in VBA too. For instance, the Form's Load event could have the following

    ControlName.Visible = False

    THis would do the same thing as setting the default in the property sheet. The difference with VBA is that you can choose events to change the properties back and forth at will.

  8. #8
    Chekotah is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2014
    Posts
    32
    Thank you. That worked. Now on to the next phase of this. Creating a sign form so multiple users.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-16-2013, 11:36 AM
  2. Replies: 14
    Last Post: 12-06-2012, 11:25 AM
  3. Replies: 5
    Last Post: 11-01-2012, 09:26 AM
  4. Replies: 12
    Last Post: 04-07-2012, 12:09 PM
  5. Replies: 10
    Last Post: 01-10-2011, 07:52 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