Solved

Locking the first record on the form

Posted on 2015-01-22
10
120 Views
Last Modified: 2015-01-22
I want to lock the first record that shows up on my form as that is my running tab for the other records
0
Comment
Question by:Jass Saini
10 Comments
 
LVL 35

Expert Comment

by:PatHartman
ID: 40564724
You would need to use a form with two subforms to make this visual.  Keep in mind that you are not working with a spreadsheet any more where any row can be anything and they don't have to all be a same.  In a relational database, all rows of a recordset are equal and identical in format.  You can't "freeze" one at the top of a form.  If you require logic like this, it is most likely because your tables are improperly normalized.  Can you give us more information.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40564755
JAss SAini,

Yes, I too am confused,...
How is your table designed so that this arrangement is required?

Or better yet, ...post a simple example of the first record and the second record...

I am not sure I understand the reason for this rather unique request

JeffCoachman
0
 

Author Comment

by:Jass Saini
ID: 40564776
Hello Pat,

My table is normalized and I know that I am not working with spreadsheets..Thank You!  

My first is based off my query...  Allocating funds to different programs...

My second record (New record) is where the analyst will show their inputs.  

When I checked the first is editable...and I know this should be the case for the fields..
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40564840
Insert this single line of code in your OnCurrent event of the form:

Private Sub Form_Current()
    Me.AllowEdits = (Me.CurrentRecord > 1)
End Sub

/gustav
0
 

Author Comment

by:Jass Saini
ID: 40564928
Thank You Gustav...
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 40564929
Record 1 does not belong in the same table as the subsequent records if what you are saying is that record 1 is a summary of the subsequent records.  This should be broken into two tables.

PS - although gustav's solution will probably work if your users are not inclined to alter the sorts of subforms, if the user does sorts the recordset, you will be able to update any record that is not the first.  And that means that if the "first" record ends up not first due to sorting, the user will be able to edit it.

If there is some identifier in the record that identifies the "first" record, then you can use my two subform solution so that the first subform shows the parent record and the second subform shows the details.  This is not right in the pure sense but it will solve the problem without requiring you to create a second table.
0
 

Author Closing Comment

by:Jass Saini
ID: 40564931
Thank You
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 40564943
I don't expect any points because I didn't provide a Band-Aid solution to an improper design, but just be aware that your users will be able to update the "first" record if they sort the subform.
0
 

Author Comment

by:Jass Saini
ID: 40564953
Thanks Pat for the heads up...Just to let you know I did change my table...I just need to read more on normalization.  i don't think anyone here is an expert at Access..so a lot of us are learning as we go.
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 40564970
Good move.  It is always better to get the schema straight in the beginning.
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

Title # Comments Views Activity
Access 2016 7 35
Combobox row source 2 21
MS Access 2010 Close Form  Event - Stop Form Closing 4 28
Help with DoEvents 8 28
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

778 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