Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-06-22
9
Medium Priority
?
536 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

715 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