show query result in a form

car20

New member
Local time
Today, 17:46
Joined
Sep 16, 2009
Messages
8
Hello

I'm so glad to join in this forum and i hope to become a good member in this forum .

I'm beginner in access but i want to try it.

i create one db with 1 table and 1 query 1 form(for phone book)

at form i have search button to find record but when i click this result show in a query not into the form's text box.

please help me how do i can show query results in form not in query page .

so sorry for my bad language.

Thanks
 
Last edited:
Welcome to Access-Programmers.

It can be hard for new users to describe their problem but it is even harder for us to understand. However I think your description sounds like your button is opening a query rather than finding a record.

You should take a close look at some sample databases provided with Access or from the internet. Unfortunately the first part of the learning curve is quite steep.

Sorry I can't be more helpful yet.
 
Hello

Thank you Dear GalaxiomAtHome ,:)

please see attached file ,

in this db for example i want to search sam's phone

i run form1 and clicked on search button and Write sam
i want sam information shown in form window but access open and show sam's info in another window .

can i describe about my problem ?
 

Attachments

You're getting the record in a query because that's what the cmdFind button is set up to do! To have the record retrieved into your current form, in your form’s code module, find this code
Code:
Private Sub CmdFind_Click()
On Error GoTo Err_CmdFind_Click

    Dim stDocName As String

    stDocName = "Query1"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_CmdFind_Click:
    Exit Sub

Err_CmdFind_Click:
    MsgBox Err.Description
    Resume Exit_CmdFind_Click
    
End Sub
and replace it with this
Code:
Private Sub CmdFind_Click()
On Error GoTo Err_CmdFind_Click
 
 Dim rs As Object
 Dim SearchName As String
 
 Set rs = Me.Recordset.Clone
 
 SearchName = InputBox("Please Enter Name for Search", "Enter Name")
    
 rs.FindFirst "[Name] = """ & SearchName & """"
 
  If Not rs.EOF Then Me.Bookmark = rs.Bookmark

  If rs.NoMatch Then MsgBox "Name Not Found!"
  
Exit_CmdFind_Click:
    Exit Sub

Err_CmdFind_Click:
    MsgBox Err.Description
    Resume Exit_CmdFind_Click
    
End Sub

I should warn you, the use of Name as the name of a field is very dangerous! Name is a Reserved Word in Access, and sooner or later this will get you in trouble! I would change the name to something else, such as MemberName or EmployeeName or some such. If you do, be sure to change the [Name]

in the line

rs.FindFirst "[Name] = """ & SearchName & """"

to whatever new name you give it.
 
Thanks

WoW !

Thank you very much ,You are access God :)
Thanks so much a bout your GUIDANCE .
i do this and solved problem;)

I think that I must learn about vba code , right ?

How Do I must start vba code ?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom