Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to open a MS Access Edit Form without showing a record

Posted on 2008-06-22
9
Medium Priority
?
537 Views
Last Modified: 2013-11-29
I'm trying to eliminate users from typing over existing data on a record in an edit form...Not an Add Form, but an Edit Form.  Therefore, I would like the EDIT form to open without any records showing (not an add form).  Then, of course, they select the correct record using a combo box.  I once knew this trick, but lost it over the years.  Any ideas out there?
0
Comment
Question by:Trudger58
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 19

Expert Comment

by:frankytee
ID: 21843558
use an unbound form with an unbound combo box (empty control source) in the forms header. this combo box has its ROWSOURCE set to whatever field you want the user to select (customer_id whatever etc). in the after update event of combo, create a recordset based on the drop box and populate the other controls (textboxes) etc with the values from the recordset.
then have a "save" button so when user clicks, the underlying table gets updated with the values from your form controls etc
0
 
LVL 19

Expert Comment

by:frankytee
ID: 21843564
of course the form controls (textboxes displaying your fields etc) are also unbound
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 1000 total points
ID: 21844285
Trudger58,

Or, you could send them to a new record when the form opens, with all the controls locked.
(*No*, this will not be an Add Form, ...all the recorde will be accessible)
;-)
...Then unlock the controls once a selection is made in the combobox.

I have attached a sample

JeffCoachman
AccessEEQ23506573OpenEditFormBla.mdb
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 77

Expert Comment

by:peter57r
ID: 21844319
I guess the 'trick' you are thinking of might be the way you set the recordsource.

If you set a where clause to return no records  (select * from mytable where 1=2)  then you will have no record visible.  Unfortunately, if you have switched off Allowadditions then you will not see any bound controls either until you select something from the combo.  
In the combo afterupdate event you set the recordsource to a single record.
"Select * from mytable where id =" & me.cbocomboname
0
 
LVL 58
ID: 21845128


  Besides manipulating the recordsource, you can also set the dataentry property to true.  When set to true, the form opens with only a blank record showing.

JimD.
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 21846487
The easiest method to pull this off would be JDettman's setting the .DataEntry property to true or false on form open.

JeffCoachman's 'roll your own' by setting each control's Locked property to True or False works too, albeit it's a bunch more coding, but depending on your situation if you have a ton of stuff going on in your form that may be needed.
0
 

Author Closing Comment

by:Trudger58
ID: 31469635
Thanks!  This will do for now, however, I recall a simple module being called on the OnOpen for the form that set the value of the primary key to either blank or null.  If y'all run across anything like that, let me know.  Thanks again.
0
 
LVL 58
ID: 21847203
<<albeit it's a bunch more coding, but depending on your situation if you have a ton of stuff going on in your form that may be needed. >>

  Not really, check this out.

JimD.
Function LockForm(FormName As String)
  
  Dim frm As Form
 
  Set frm = Forms(FormName)
  LockForm = StdLockForm(frm, True)
 
End Function
 
 
Function StdLockForm(frm As Form, intState As Integer)
  
  'Lock/unlock all the fields in the detail section of the form that are enabled.
 
  Dim intL As Integer              'Generic loop counter
  Dim intCount As Integer          'Number of controls on the form
   
  intCount = frm.Count             'Find out how many controls are on the form
 
  On Error Resume Next
  For intL = 0 To intCount - 1      'Step thru all controls on the form
    If (frm(intL).Section = False) Then 'Don't do any control execpt those in the detail section
        If (frm(intL).Enabled = True) Then frm(intL).Locked = intState   'Set 'Locked' property to proper state
    End If
  Next intL
  On Error GoTo 0
 
End Function

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 21848138
Trudger58,

As you can see there are many way to do this.
Switching modes while the form is open is always tricky (at least for me)
You always have to balance:
What the user will need to do, what they might want to do, and what you don't want them to do.
;-)

JeffCoachman

0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Progress

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question