Saving and Closing Forms

L

Lloyd

I am having "permission" and "more than one user" issues
in my application (Access97) that I suspect is related to
having more than one form open at a time. What is
the "rule" for saving and closing single record forms? If
I am going from one form to another in the same
table/record using a macro, should I always save the
record and close the form before opening the new form?

How do I assure that the current record remains the active
record in the new form?

Should I use a tabbed form for this type of data?

Thanks,

Lloyd
 
G

Graham Mandeno

Hi Lloyd

If you have dirtied the record in one form, then you cannot edit it in
another without getting these conflict messages. You don't need to close
the first form, but you must save the current record:

If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
(or Me.Dirty = False also does the trick)

To open the new form showing a particular record, use the WhereCondition
argument (4th) of OpenForm. For example:

DoCmd.OpenForm "Form2", , , "[KeyField]=" & Me.KeyField

This will filter the second form to show only those records matching the
WhereCondition.

If you want to show *all* the records in the second form, but navigate to
the matching record when the form opens, then use the OpenArgs argument:

DoCmd.OpenForm "Form2", OpenArgs:=Me.KeyField

Then, in the second form's Form_Load procedure:

If Not IsNull(Me.OpenArgs)
With Me.RecordsetClone
.FindFirst "[KeyField]=" & Me.OpenArgs
If Not .NoMatch Then Me.Bookmark = .Bookmark
End With
End If
 
J

John Vinson

I am having "permission" and "more than one user" issues
in my application (Access97) that I suspect is related to
having more than one form open at a time. What is
the "rule" for saving and closing single record forms? If
I am going from one form to another in the same
table/record using a macro, should I always save the
record and close the form before opening the new form?

How do I assure that the current record remains the active
record in the new form?

Should I use a tabbed form for this type of data?

The "Save" option on closing forms is a bit misleading. It refers to
saving *design changes to the structure of the form itself*, and has
nothing whatsoever to do with saving data. When you close a form
(unless you're deliberately changing the actual layout or properties
of the form itself) you should always use the acSaveNo option.

The data in a Form is saved automatically, without any need to do
anything programmatically, as soon as the user moves off the current
record or closes the form. You can block this from happening (with the
Form's BeforeUpdate event for instance) but you don't need to do
anything to make it happen.

If you have multiple forms referencing the same record... don't!
Instead, if necessary, use a single form with tab pages. If you're
opening a second form to enter data into a related table, you may want
to consider using a Form for the "main" table, with a Subform for the
"many" table; this keeps the linking ID field synchronized
automatically for you.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
G

Guest

John and Graham,

Thanks for the useful information. In places where I am dealing with a
single table, it is clear that I should be using a tab form. I have tried
copying a group of controls from an existing form to a tab control.
Unfortunately, I can't get them to copy to a single "page" or "tab". They
copy to both pages. Is there a trick to doing this copy in Access97?

Secondly, is it appropriate to put a subform (with data from a related table
- one-to-many relationship) on a tab of the "parent" form? (I have lots of
data and being able to use tab controls in this way would be very helpful.)
Or should I simply open a new form and close the originating one?

Thanks.

Lloyd
 
G

Guest

Thanks John and Graham. Your info was very helpful.

It is clear that I should be using tab controls in a couple of situations.
I have tried copying a group of fields from an existing form into a tab on
another form. However, the "copy" always seems to go to both tab pages. Is
there a trick in Access97 to copying a group of fields from a different form
into a tab page?

Secondly. Is it appropriate to place a typical subform (data on the many
side of a one-to-many relationship) on a tab of the "parent form"?

Thanks, Lloyd
 
J

John Vinson

It is clear that I should be using tab controls in a couple of situations.
I have tried copying a group of fields from an existing form into a tab on
another form. However, the "copy" always seems to go to both tab pages. Is
there a trick in Access97 to copying a group of fields from a different form
into a tab page?

Yes, there *is* a trick. You need to select the control or controls;
type Ctrl-X to cut them to the clipboard; click the *TAB* of the tab
control (not its surface, the little labeled tab instead) to select
the page; then type Ctrl-V to paste the controls. They can then be
moved around where you want them.
Secondly. Is it appropriate to place a typical subform (data on the many
side of a one-to-many relationship) on a tab of the "parent form"?

If you need the screen space, sure.

Just a note: if you have SO MANY controls on a form, all bound to a
single table, that you need two or more screenfuls of space to hold
them - your table design may need examination. If you have over 30 or
so fields in your table, consider carefully whether or not you need to
normalize; might you have some one to many relationships, or multiple
entities, embedded within each record of your table?

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

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