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!

Opening form based on combo box in other form

Status
Not open for further replies.

Grieg

Technical User
Sep 13, 2002
20
GB
Hi,

I have a form (select_client) where I have a combo box (clients) showing certain fields from a table.

When a record has been selected from the combo box and the user clicks on an item (select) I want another form to open up showing all the fields from this record.

The code I am using is;

Private Sub select_Click()

Dim stDocName As String
Dim rs As Object
stDocName = "View_amend_client"

Set rs = Me.RecordsetClone
DoCmd.OpenForm stDocName
rs.FindFirst "[ID] = " & Str(Me![clients])
Set Forms!View_amend_client.Bookmark = rs.Bookmark
Set rs = Nothing
DoCmd.Close acForm, "Select_client"

End Sub


The problem is I'm getting an 'object required' error with my 'Set' statement.

Any help would be greatly appreciated.
 
Hi,
Try replacing your Dim rs as Object with

Dim rs as DAO.Recordset Hope it helps. Let me know what happens.
With regards,
PGK
 
Thanks for your post.

I've tried putting that in but it threw up a 'user defined type not defined' error. Prior to this I had tried;

Dim rs as Recordset

however this made it come up with a 'method or data member not found' error in the Findfirst statement.

Back to the drawing board!!

Thanks for your reply.

Grieg.
 
You do not say whether the Form you are trying to open, "View_select-Client" already exists. If it doesn't, your procedure can't find it, hence the "object required" Error. In that case, just create the form with objects to match your requirement; everything should then work.

If I am right, don't worry - we have all done it more than once!
 
This is one way to do it...

Code:
Private Sub select_Click()
Dim Client As Variant
Client = Me!clients
DoCmd.OpenForm "View_amend_client"
DoCmd.GoToControl "ID"
DoCmd.FindRecord Client
DoCmd.Close acForm, "Select_client"
End Sub

-TH-
 
One way I have done it is to design a query for the info I want from the db. Based the form that I want to display the search results on the query. Have the criteria for the query based on the combo box on the first form.

(select_client) combo box (clients)
query= qrySearchClient (has all the fields you want to display for the search). In the criteria of the ClientID field [FORMS]![frmselect_client].[cmboclients]

Base the search results form on the query qrySearchClient
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top