Forms in Combo Box

S

SeRene

Hi,

I've made use of a combo box to list all the Forms i have
in my database. I've made use of the SQL codes as shown ->
SELECT MSysObjects.Name AS ObjectName
FROM MSysObjects
GROUP BY MSysObjects.Name, MSysObjects.Type
HAVING (((MSysObjects.Type)=-32768))
ORDER BY MSysObjects.Name;

The problem is.. I've actually created the forms to be of
Datasheet View. However, when i select any of the forms
from the combo box, the form will display as a Single Form
Type. Is there anything wrong with my ?SQL codes?? Coz if
i do not make use of the combo box and simply double click
on the form itself, it appears in Datasheet View.
 
J

Jeff Conrad

Nothing wrong with your SQL, just the calling parameters
to open the forms. The default constant for opening a form
is in Single View (acNormal) unless specified otherwise in
your code, even if you have it set as a Datasheet. You
need to add the acFormDS argument to tell Access to open
the form in Datasheet mode.

Right now your code is probably something like this for
the combo box After_Update event:

Private Sub cboSelectForm_AfterUpdate()

Dim strFormName As String
strFormName = Me.cboSelectForm.Value

DoCmd.OpenForm strFormName

End Sub


Change that to this:


Private Sub cboSelectForm_AfterUpdate()

Dim strFormName As String
strFormName = Me.cboSelectForm.Value

DoCmd.OpenForm strFormName, acFormDS

End Sub

Now each form will open in Datasheet mode after you make a
selection from the combo box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top