Help opening form

haveli1

New member
Local time
Yesterday, 18:52
Joined
Jul 24, 2006
Messages
9
I have this bit of code that pulles up the query "ID answer" based on inputs the user gives. I wanted to open the first record on that list of "ID Answer." in a form view. I added the openform function but it does not work. It does not open the form. I was wondering if anyone had any suggestions.

Basically if the user inputs the name=Joe. The query finds all the records with the name joe. This part works. Now I want it to open up the form of the first record in that list.


With CurrentDb

.QueryDefs.Delete ("ID Answer")
Set qdfNew = .CreateQueryDef("ID Answer", query)
.Close
End With

DoCmd.OpenQuery "ID Answer", acNormal, acEdit
DoCmd.OpenForm "Form1", acNormal, , , , , "ID Answer"
End Sub
 
haveli1 said:
I have this bit of code that pulles up the query "ID answer" based on inputs the user gives. I wanted to open the first record on that list of "ID Answer." in a form view. I added the openform function but it does not work. It does not open the form. I was wondering if anyone had any suggestions.

Basically if the user inputs the name=Joe. The query finds all the records with the name joe. This part works. Now I want it to open up the form of the first record in that list.


With CurrentDb

.QueryDefs.Delete ("ID Answer")
Set qdfNew = .CreateQueryDef("ID Answer", query)
.Close
End With

DoCmd.OpenQuery "ID Answer", acNormal, acEdit
DoCmd.OpenForm "Form1", acNormal, , , , , "ID Answer"
End Sub

Form1's recordsource needs to be set to the query ID Answer. I am assuming that query in .CreateQueryDef("ID Answer", query) is a string containing the correct SQL to return the records you want. All you would need to do then is open the form.

HTH

K.
 

Users who are viewing this thread

Back
Top Bottom