Opening Form w/out Displaying a Record

F

fridayxiii

I think this is a basic question but so far I've been unable to find
the answer.

I have a form, frmMain that includes two subforms: fsubModules &
fsbuProjects. When frmMain is opened I'd like that form (2 combo
boxes) to be blank, as well as both subforms. I've been looking thru
the list of events, & found the OnLoad event, but I don't know what
code or expression to add.

As background this d/b & form will primarily be for read or view
access, and not used for record entry. Record entry is done thru a
different Access d/b whose tables link to the subforms.

Thx!
Brian
 
G

Guest

Forms have three states:
At record, At new record, No Record.

In the No Record state, the Body of the form is not
painted. Only the header and footer section are displayed
correctly.

The header and footer sections display correctly because
they don't depend on the current record. The main section
is not displayed correctly because it depends on the current
record.

You can't move to the No Record state (you can't unpaint
the main section of the form). You can only move between
At record and At new record. When you move off all of
the records, you move to a new record. If you can't create
a new record, you can't move off the last record.

The form opens in the No Record state, not opened
correctly, not painted, only if it can't find a record to
allow it to open correctly. That is, if the recordset
is empty and it or the form does not permit new records.

"Select a,b from c where (a=true) and (a=false)"

So if you have a separate add-record form, you must
not put the controls for it in the main section of the form!

(david)
 
G

Guest

Hi fridayxiii

I presume the when you select an item from the combo box you want the
subforms to requery and refresh based on the item selected on the combox?

If so you need to reference the combo boxes on the main form from the record
sources of your subforms.

e.g.

Relationship field on both the main form and subforms the query selection
criteria for the field would be something like

Forms!frmMainForm!cboComboBox1.Column(BoundColumn#)

do this for fields that have a relating combo box on your main form.

On the AfterUpdate event of the combo boxes you'll need to put something like

Me.fsubModules.Requery
Me.fsbuProjects.Requery

having the selection criteria in the subform record souce will make the sub
forms show nothing when the main form is opened because there is nothing
selected in the either of the combo boxes. Once you have made a selection in
the main form combo boxes, you then need to requery the sub forms and they'll
will show any relating records that match the values selected in the combo
boxes.

Tip: If you want to have the first item selected in a combo box when the
form opens, use Me.cboComboBox = Me.cboComboBox.ItemData(0)

HTH

KM
 
F

fridayxiii

Thanks much Kevin, I think this'll do the trick! I added the code to
default the first cbo to the first list value, so I think the rest of
the code should be perfect. BTW, you intuited my intent correctly as
well. Thanks agan for the help!!!

-=Brian
 

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