Open Access Objects with combo box

RossW

Registered User.
Local time
Today, 08:52
Joined
Oct 17, 2000
Messages
10
Is is possible to open a specific form or query with a combo box?

thanks,

Ross
 
I think so mate, I have asked a similar thing in my query which I posted earlier, when and If I get a reply to mine, Ill post you a copy!

Jamie
 
I'm not sure I understand your question fully, but it is easy to open a form or run a query using a combo box. On the After Update event, put in the code:
Docmd.OpenForm "YourFormName"
or
Docmd.OpenQuery "YourQueryName"

You also can set arguments based on the value of the combo box that will filter the form or provide criteria for the query. Look under DoCmd Object in help, or post more details about what you want to do.
 
The database has a number of forms. I presently have a number of buttons that are used to specify which form to open. I thought I could clean up the screen by having one or two combo boxes that would permit the user to select the form (or query) that they want to open. I want to have a combo box filled with a list of forms that are part of the database. Is it possible to fill a combo box with a list of form objects?

thanks
 
Create a Table called tblForms with three fields...

FormID Autonumber
Form_Name Text
Form_Friendly_Name Text

Create some records with the actual name of the forms you would like to open in the Form_Name field, and a description for the users to read from your combo in the Form_Friendly_Name field.

Now create a form, and place a combo box on it. Link the combo box to your table and bring the FormID and the Form_Friendly_Name fields into the combo, hiding the FormID.

So now you should have a form with a combo on it that display the 'friendly names' you have created.

On the AfterUpdate event of your combo place the following code...

Dim db As Database
Dim rs As Recordset
Dim intFormID As Integer
Dim strSQL As String

Set db = CurrentDb

intFormID = Me.cboForms.Value


strSQL = "SELECT tblForms.FormID, tblForms.Form_Name " & _
"FROM tblForms " & _
"WHERE tblForms.FormID= " & intFormID

Set rs = db.OpenRecordset(strSQL)

With rs
.MoveFirst
DoCmd.OpenForm .Fields("Form_Name")
End With
rs.Close

Hopefully this will resolve your problem, or at least point you in the correct direction.

Whenever you want to give the user the ability to open another form from the combo you simply have to enter another record in the table - simple.

[This message has been edited by Former (edited 11-16-2000).]
 
You can use a variable set to the value of the combo box to designate what form to open or query to run.
Your code would be

dim stForm as string
stForm = YourComboBox

Docmd.OpenForm stform
 

Users who are viewing this thread

Back
Top Bottom