FORM for viewing only

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

Can someone please help me...

I am trying to set a command button that will close a form
without saveing the record, but if any of the fields on
the form are changed the record is saved...

This is the same form used for data entry, so a new record
is created on each save, and there is no record selection
options on the form...
 
bob said:
Can someone please help me...

I am trying to set a command button that will close a form
without saveing the record, but if any of the fields on
the form are changed the record is saved...

This is the same form used for data entry, so a new record
is created on each save, and there is no record selection
options on the form...

I don't follow you. If none of the fields on the form have been
changed, the record won't be saved anyway. How is what you're asking
for different from the normal form behavior?
 
NEVER MIND, SORRY
I have resolved it with the following CODE, But I am VERY
Open to other opinions...
Thanks
===================================
Private Sub CloseNoSave_Click()
On Error GoTo Err_CloseNoSave_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, ,
acMenuVer70
DoCmd.Close

Exit_CloseNoSave_Click:
Exit Sub

Err_CloseNoSave_Click:
MsgBox Err.Description
Resume Exit_CloseNoSave_Click
End Sub
=======================================
 
Bob said:
NEVER MIND, SORRY
I have resolved it with the following CODE, But I am VERY
Open to other opinions...
Thanks
===================================
Private Sub CloseNoSave_Click()
On Error GoTo Err_CloseNoSave_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, ,
acMenuVer70
DoCmd.Close

Exit_CloseNoSave_Click:
Exit Sub

Err_CloseNoSave_Click:
MsgBox Err.Description
Resume Exit_CloseNoSave_Click
End Sub
=======================================

Oh, I think I see. I misinterpreted your original question. Is there a
reason you can't open the form as read-only in the first place? For
example,

DoCmd.OpenForm "YourForm", DataMode:=acFormReadOnly

(Note: that would render even unbound controls nonupdatable, which could
present a problem.)
 
The form is opened from a switchboard sub menu, not sure
how to add that line of code into the switchboard module...
(THAT MODULE REALLY IMPRESSES ME!!)
Also this form is full of unbound controls...

A Little back ground..
its a questionnaire DB
2 front-ends; questionnaire, and admin (non-tech admin)
one back-end

administrator uses the admin FE to select and assign
questions to a questionnaire form (which is what is
populated with the unbound controls) but the form used to
select the questions is not like the questionnaire, So I
wanted to provide a view of what they had created...

ALL VERY PRIMATIVE, BUT PRETTY NICE FOR A BEGINER
 
Bob said:
The form is opened from a switchboard sub menu, not sure
how to add that line of code into the switchboard module...
(THAT MODULE REALLY IMPRESSES ME!!)
Also this form is full of unbound controls...

A Little back ground..
its a questionnaire DB
2 front-ends; questionnaire, and admin (non-tech admin)
one back-end

administrator uses the admin FE to select and assign
questions to a questionnaire form (which is what is
populated with the unbound controls) but the form used to
select the questions is not like the questionnaire, So I
wanted to provide a view of what they had created...

ALL VERY PRIMATIVE, BUT PRETTY NICE FOR A BEGINER

<G>

It's possible to modify the switchboard module to add a function "Open
Form Read-Only", but it's more elaborate than you want and besides, if
the user is supposed to be able to modify unbound controls on the form,
opening it read-only won't work.

Another possibility is that, if there's a way the form "can tell" that
it's being opened in "viewing mode", you can have code in the form's
Open event that locks all the bound controls and sets the AllowDeletions
and AllowAdditions properties to False. That way the current record
can't be modified, and so won't be saved.

However, if you have a working solution you may not want to muck around
with all this code.
 
Back
Top