Users creating blank records when clicking new record on navigation form (1 Viewer)

antimoneylaundering

New member
Local time
Yesterday, 20:27
Joined
May 18, 2018
Messages
4
When a user opens the database the Welcome form opens. The Welcome form has command buttons; when clicked, they create a new record on the corresponding form.

They have been clicking the wrong button, going to the wrong form, closing the form, and creating a blank record. I don't want them to get a message box saying that a field is required because they don't have anything to enter on that form.

The next time the button is clicked it goes to a new record and leaves the blank record.

I have a command button on the form that doesn't allow them to create a new record without filling in the required fields. It's just the Welcome page that's a problem.

Apologies if this has been answered. It's entirely possible I wasn't searching with the correct keywords.
 

Ranman256

Well-known member
Local time
Yesterday, 23:27
Joined
Apr 9, 2015
Messages
4,339
then when they open that form , dont allow new records there.
in the form design, turn off ALLOW ADDITIONS
 

Mark_

Longboard on the internet
Local time
Yesterday, 20:27
Joined
Sep 12, 2017
Messages
2,111
Are you adding a blank record then opening the form to edit the blank record?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:27
Joined
Feb 28, 2001
Messages
27,148
This is the right place to ask, but we might need to consider a few things first.

It sounds like the problem is in the way you bring up the "wrong form" (as you put it). However, there is a way to recover this. In the form's Before_Update event, if you ran a test (call it a sanity check), you would be able to determine if every field on the form was blank or was equal to any default values that might be in force. If so, you could execute an "Undo" on the form so that the newly created record would be undone, then let it close on its own.

Note that if the 2nd form (the one being opened by the Welcome form) is bound but you don't allow users to see previously entered records - which I understand - then it HAS to show something and that something is usually a blank record. Your idea of having the "Save" button or equivalent so that you can do the validation testing - that's great and is certainly one of the best ways to go.

But the question is, what happens in that form in the Form_Open or Form_Load events (or what happens in the code that opens the form from the Welcome screen's command button)? That is actually where your problem lies.

Final note: If the secondary forms create new records with autonumbers, you will have gaps in those numbers because of this. That's a different question than the "blank record" question. But I won't make a guess at that part right now.
 

antimoneylaundering

New member
Local time
Yesterday, 20:27
Joined
May 18, 2018
Messages
4
They are able to view and edit previous records. Obviously not ideal, but they make a lot of mistakes.

I'm a VBA newbie so this may be totally wonky.

This is code I have for the command button click on my Welcome form.

Private Sub cmd_open_frm_cs06_Click()
DoCmd.OpenForm "frm_cs06", acNormal, "", "", , acNormal
DoCmd.ApplyFilter "", "[critical_process]=""3""", ""
DoCmd.GoToRecord acForm, "frm_cs06", acNewRec
End Sub

I don't have any Form_Open or Form_Load events on the 2nd form.

In terms of gaps between numbers - That's totally fine. i just don't want blank rows in the table.
 

Mark_

Longboard on the internet
Local time
Yesterday, 20:27
Joined
Sep 12, 2017
Messages
2,111
DoCmd.GoToRecord acForm, "frm_cs06", acNewRec

What is a cs06? Most objects should be named in such a way that you can easily tell what they are for. FrmUpdateOrder is pretty self evident.

Otherwise it looks like you are doing the right thing. I am guessing the form itself has a 'save' button? If so, you may want to disable it if they have nothing to save. I've see this behavior before. User gets used to hitting "Save" as "Close".
 

June7

AWF VIP
Local time
Yesterday, 19:27
Joined
Mar 9, 2014
Messages
5,466
AFAIK, the second acNormal is not in the list of constants for that argument, acWindowNormal is. However, both constants represent the same value so it seems to work regardless. Since Normal is the default can just omit the explicit reference. Also, acForm is not in the constants list and acDataForm is and again, both represent same value and work. I am using Access2010.

I would simplify the filter expression by using apostrophes (easier to read). Is critical_process actually a text type field?
DoCmd.ApplyFilter , "[critical_process]='3'"

Code tested and cannot replicate issue. What do you mean by 'navigation form' - do you mean a Navigation Form, as in the Navigation Form from the Design tab?
 

antimoneylaundering

New member
Local time
Yesterday, 20:27
Joined
May 18, 2018
Messages
4
Without going into too much detail. The users work based off of a procedure id. The procedure id CS06. Oddly, nobody has the actual titles memorized; they fall apart if they don't see the id. I learned that one hard way.

When the form is closed it automatically saves. If I open the form and close the form without saving there is still a blank row in the table.

Is there a setting that I need to change?
 

June7

AWF VIP
Local time
Yesterday, 19:27
Joined
Mar 9, 2014
Messages
5,466
No setting that I know of, must be some code somewhere. If you want to provide db for analysis, use Attachment Manager in the Advanced Editor to provide file.
 
Last edited:

Mark_

Longboard on the internet
Local time
Yesterday, 20:27
Joined
Sep 12, 2017
Messages
2,111
You are describing a dirty record. Do you have something on the form to fill in fields to default values? Is something making a change in any way to the 'blank' record?

This could be something that seems so normal, such as a default value hidden some place.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:27
Joined
Feb 19, 2002
Messages
43,233
What is the point of applying a filter if you are going to always go to a new record?

Just opening the form to a new record does not cause that new record to be added. Either the user is typing something into one of the controls or you have code that is dirtying the record. If it is your code that is dirtying the record, move the code to the Form's BeforeInsert event so your code won't run until some user types something first.

Once "you" stop dirtying the record, then you would use Doc's suggestion. In the BeforeUpdate event of the record, you need code that determines that all required fields are present and the validation code should also validate other fields such as dates for sanity. For example, it makes no sense for a birth date to be in the future or the birthdate of an employee to be < 16 years ago or more than 70 years ago, etc. You can have the code accept older employees after prompting the user to confirm the age but laws prevent hiring people under 16 except for certain kinds of jobs.
 

Users who are viewing this thread

Top Bottom