Solved

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

Posted on 2008-06-22
9
527 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 250 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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 57
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 65

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 57
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

770 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