473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Disable entry of a new record in a form

iBasho
16
Hi, I have created a form that will be used to enter information into a table. The form is set up so that it pulls up only the blanc "new record" line from the table that way the user sees an empty form. Unfortunately once you start entering data the new record navigation button gets enabled and if you scroll down using the mouse wheel you end up on another new blanc record.
I don't want people to accidentally move onto record 2, they will never need to enter more than one record.
I tried to set the Allow Additions property to 'No', but when I do that I can't see my form anymore.
Is there any way to prevent the addition of a new record once you start entering data?
Mar 10 '07 #1
10 18893
MMcCarthy
14,534 Expert Mod 8TB
In the form properties remove the Navigation buttons.

Mary
Mar 10 '07 #2
iBasho
16
Thanks. I tried your solution, but it doesn't resolve my problem completely. When the users scroll down (the form is too long) and they use the mouse wheel they automatically see the new record, regardless if there are navigation buttons or not.
Is there anything that can be done to prevent the automatic addition of a new record?


Thanks again.
Mar 10 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Thanks. I tried your solution, but it doesn't resolve my problem completely. When the users scroll down (the form is too long) and they use the mouse wheel they automatically see the new record, regardless if there are navigation buttons or not.
Is there anything that can be done to prevent the automatic addition of a new record?


Thanks again.
Is this a continuous form?
Mar 10 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
Is this a continuous form?
If it is change it to single form view. Now to turn off the mouse wheel have a look at Stephen Lebans MouseWheel on/off solution.

Mary
Mar 11 '07 #5
NeoPa
32,556 Expert Mod 16PB
Thanks. I tried your solution, but it doesn't resolve my problem completely. When the users scroll down (the form is too long) and they use the mouse wheel they automatically see the new record, regardless if there are navigation buttons or not.
Is there anything that can be done to prevent the automatic addition of a new record?


Thanks again.
Create a
Expand|Select|Wrap|Line Numbers
  1. Private Form_BeforeUpdate(Cancel As Integer)
event procedure which checks that all the data has been entered correctly and, if it has not, sets Cancel = True.
Mar 11 '07 #6
ADezii
8,834 Expert 8TB
Hi, I have created a form that will be used to enter information into a table. The form is set up so that it pulls up only the blanc "new record" line from the table that way the user sees an empty form. Unfortunately once you start entering data the new record navigation button gets enabled and if you scroll down using the mouse wheel you end up on another new blanc record.
I don't want people to accidentally move onto record 2, they will never need to enter more than one record.
I tried to set the Allow Additions property to 'No', but when I do that I can't see my form anymore.
Is there any way to prevent the addition of a new record once you start entering data?
If all your Data has been entered correctly via NeoPa's approach, and the User 'never' has to enter more than 1 New Record, you can place a DoCmd.Close in the AfterUpdate() Event of your Form. This is a little unorthodox, and not exactly good Database practice, but it will accomplish what you are looking for, I think. To recap all that has been said:
__1. Form should be in Single Form
__2. Disable Navigation Buttons
__3. Thorough Validation Code in the BeforeUpdate() Event
__4. Data Entry = True
__5. DoCmd.Close in the AfterUpdate() Event of the Form
Mar 12 '07 #7
jhack
2
Hi all,

I'm also having the same problem with trying to prevent the addition of new records. My sub form needs to be able to add a record if none exists for the given id. But if one already exists, it shouldnt be able to create another.

My form is set to single form, I have disabled the nav buttons, and I have the mousewheelonoff script installed and working. The problem is that even with all that disabled, i can still hit the tab button, cycle through all the fields in view and then it will move to the new record.

Is there a way I could prevent the addition when one record already exists? Perhaps in the form_load code, but I'm not sure how to check if a record exists or not.

thanks for any help.
Apr 9 '07 #8

...The problem is that even with all that disabled, i can still hit the tab button, cycle through all the fields in view and then it will move to the new record.
Set the Cycle property of the form to 'Current Record'. The tab key will then only cycle among the fields on the current record. Hope this helps.
Apr 9 '07 #9
jhack
2
Set the Cycle property of the form to 'Current Record'. The tab key will then only cycle among the fields on the current record. Hope this helps.

Thanks for the tip.

However, I already found another way around the issue. I'll post my solution for anyone else who might be interested. And to get feedback in case it's flawed in some way (it seems to work great though)

First, I created a textbox on the form and gave it the following properties:
Expand|Select|Wrap|Line Numbers
  1. name: txtCount
  2. visible: no
  3. control source: =Count(*)
Next, I added this line to the Form_Load event.

Expand|Select|Wrap|Line Numbers
  1. Me.AllowAdditions = AllowNewRecords()
Finally, I created the AllowNewRecords() function

Expand|Select|Wrap|Line Numbers
  1. Function AllowNewRecords() As Boolean
  2. On Error GoTo Err_AllowNewRecords
  3.  
  4. If txtCount.Value > 0 Then
  5.     AllowNewRecords = False
  6. Else
  7.     AllowNewRecords = True
  8. End If
  9.  
  10. Exit_AllowNewRecords:
  11.     Exit Function
  12.  
  13. Err_AllowNewRecords:
  14.     AllowNewRecords = True
  15.     Resume Exit_AllowNewRecords
  16.  
  17. End Function
Essentially, the way it works is that if there is a record already, then txtcount equals one and the function sets AllowAdditions to false. If there isnt any records, then the txtcount has no value and generates an error saying "You entered an expression that has no value", except I simply redirect the error to allow additions.

it's not perfect, but it works.
Apr 9 '07 #10
NeoPa
32,556 Expert Mod 16PB
Thank you for posting your solution.
It's always interesting to see solutions, even when found outside of TSDN.
Apr 10 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5...
7
by: Saintor | last post by:
What I do now is I put a value in the tag property, and using the form_current event, I run through all controls properties until the ones with the required tag value are met. Sound OK in theory,...
2
by: edworboys | last post by:
I have designed a data entry form with a number of fields and a sub form. The first field (Country) is a combo box and the user selects a country. This, in turn reduces the number of options in the...
2
by: Will | last post by:
I have a form which has a field Start Date. I want to only let the user enter a date if there is no date in the field and never be able to edit the field. I have experimented with On Enter and On...
6
by: GGerard | last post by:
Hello I have an Access 2000 form with the following properties: Record Source - Table1
14
by: Sinity | last post by:
Anyone knows the method/codes to disable the clicked button after first click by using .aspx-- to prevent people to click many time when waiting for the server response. I tried to do this by...
20
by: hippomedon | last post by:
Hello everyone, I'm looking for some advice on whether I should break the normalization rule. Normally, I would not consider it, but this seems to be a special case. I have created an...
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I disable the right mouse button? -----------------------------------------------------------------------...
3
by: Bob Alston | last post by:
Anyone know how to disable or redefine the Ctrl - hotkey which deletes a record? I have a multi page form that uses 14 records, each record handles 1-2 pages of the 18 page form. Occasionally ,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.