Solved

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

Posted on 2008-06-22
9
525 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now