Results 1 to 7 of 7
  1. #1
    ledis is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    7

    Find a record using a TextBox & Button

    Hello, basically i want to type the ID(key) of a record table in a unbound text box and then by pressing a command button to be able to bring up that record (in form view). I do not want to use a combo-box.



    So what do i write as VB code in the Private Sub mybutton_Click()

    Table name is [ACTION_ID], ID field name is [ACT_ID] & text box name is [TEXT_BOX]

    Thank you

    Click image for larger version. 

Name:	home.jpg 
Views:	16 
Size:	31.8 KB 
ID:	15235Click image for larger version. 

Name:	ID_form.jpg 
Views:	16 
Size:	74.1 KB 
ID:	15236

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Why don't you want to use a combo box
    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
    ledis is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    7
    Hi thanx for the reply, I think i got a far as this point :

    using this code on the button

    Private Sub mybutton_Click()

    DoCmd.OpenForm "ACTION_ID", , , "ACT_ID ='" & Me.TEXT_BOX.Value & "'"

    End Sub

    But this works if the [ACT_ID] cell is type TEXT (wont work if its NUMBER, would be cool to know what to add or remove in the code so i can use a NUMBER type cell)

    and also can you help me with adding a "This ID does not exist" message if an [ACT_ID] that does not exist is looked up?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Cross post see: http://www.access-programmers.co.uk/...d.php?t=260356
    Please don't crosspost without telling us. Please read the following link: http://www.excelguru.ca/content.php?...-cross-posters

    If [ACT_ID] is numeric then you do not need to enclose the criteria in single quote, so try:
    DoCmd.OpenForm "ACTION_ID", , , "ACT_ID =" & Me.TEXT_BOX.Value
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    Will the user really know the "ID"???
    You may want to test your theory before doing too much programming.

    Good luck.

  6. #6
    ledis is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    7
    Im really sorry about the "cross post" never heard about it before , now i know.

    Thank you for the help, im probably going to be asking more stuff here!

  7. #7
    ledis is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    7
    Hi, yep from what i understand they have all the data on paper even the ID and then they put it in the DB.
    ...im not sure they even now what they want yet :P, i think im going to be visiting this forum a lot more times.

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

Similar Threads

  1. Report Find Record Button
    By data808 in forum Reports
    Replies: 5
    Last Post: 01-26-2014, 02:07 PM
  2. Find Record Button
    By data808 in forum Forms
    Replies: 3
    Last Post: 01-12-2014, 01:05 PM
  3. Replies: 7
    Last Post: 06-12-2012, 08:56 AM
  4. Replies: 3
    Last Post: 02-23-2010, 06:32 PM
  5. Find Record button error
    By Zedlexx in forum Forms
    Replies: 0
    Last Post: 03-11-2009, 09:26 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