Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate data from param query

Status
Not open for further replies.

yuchieh

MIS
Jul 21, 2000
178
US
I need to populate data into a form in Access from a param query.
when user clicks on a button ->
run param query ->
user enter an ID ->
find the record from that query ->
populate the ID and name of the found record into the form fields

I don't know much about the VB code. How do I write such code? Or is there a way to do in Macro?

Please help!! Thanks
 
not quite the way I wanted. I don't want to find a record on the form. I want to find a record from the query and insert the data into the form.

Thanks.
 
Here is a sample code
tested in access 2002
Code:
Private Sub cmdOpenRec_Click()
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sSQL As String
    Set cn = CurrentProject.Connection
    Set rs = New ADODB.Recordset
 sSQL = "SELECT  * " & _
       "FROM  yourtable " & _
       "WHERE yourtable.recnum =" & [Forms]![YourForm]![txtSearch]

    rs.Open sSQL, cn
    
    Me.Text2 = rs.Fields(1)
    Me.Text4 = rs.Fields(2)
    
    rs.Close
    cn.Close
    Set rs = Nothing
    Set cn = Nothing
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Why not simply use a ComboBox to find the info in the lookup table ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top