Cancel Adding New Record

Jun 15, 2007

am using VB to check for an id if it is a new record. i have a message that pops up.

If IsNull(Form_myform![ID].Value) Then
response = MsgBox("You have not entered your ID. Do you intend for this to be a record?", vbYesNoCancel, "id check")

but how do i get it to not enter the record into the table if no or cancel is clicked?

View Replies


ADVERTISEMENT

Cancel Adding New Record If Condition Is True

Oct 11, 2007

Hi

I wrote code that should validate a field when entering a new record and then if a condition is true, that new record should be cancelled and not entered into the table.

I managed to partially achieve this by writing the code below, but the new record does not get cancelled because the table will still create a PK for that record and leave the rest of the fields empty. I am using an autonumber for the PK that's why the table creates it automatically What I want to achieve is to cancel the creation of a new record at once, I don't want even PK created for that new record.

I used the CancelUpdate because I thought it would cancel the record creation, but it did not! When I read about it it said that I need to use it with either Edit or AddNew, (which i don't understand why!) but it still does not work.

Private Sub PlotNum_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_msg
Dim db As DAO.Database, rs As DAO.Recordset
Dim n As Integer, i As Integer
Dim vPlotNum As Integer
Dim vPhaseID As Integer

vPhaseID = Forms![frmHouse].Form![PhaseID]
vPlotNum = Forms![frmHouse].[qryHouse2].Form![PlotNum]

Set db = CurrentDb
Set rs = db.OpenRecordset("tblHouse")
rs.MoveLast
n = rs.RecordCount
rs.MoveFirst
If n > 0 Then
For i = 1 To n
If rs![PhaseID] = vPhaseID Then
If rs![PlotNum] = vPlotNum Then
rs.Edit
rs.CancelUpdate
MsgBox "This plot number already exist in this particular phase." & vbCrLf & "Please choose a different Plot Number"
Forms![frmHouse].qryHouse2.Form![PlotNum].Text = ""
End If
End If
rs.MoveNext
Next i
End If
rs.Close
db.Close
Set db = Nothing
Set rs = Nothing

Exit_Err_msg:
Exit Sub

Err_msg:
MsgBox Err.Description
Resume Exit_Err_msg
End Sub


Any suggestions will be very much appreciated.
Thanks.
B

View 14 Replies View Related

Cancel Record In Subform If Click Cancel On Parent Form Before Save

May 24, 2014

I have a form and a subform in it. I added New cancel button in the form so that the the user can cancel the record creation and no record will be inserted in the parent table.

But when details are entered in the subform (a datasheet) row records will be created in the subform table. what is the correct method or how to cancel these records if the user choose to click cancel button on the parent form.

View 5 Replies View Related

Cancel New Record Command

Jan 26, 2005

Folk,

I'm using the default command to add a new record in a table:

DoCmd.GoToRecord , , acNewRec

The question is: How I can cancel the new record inclusion on table? It's possible?

Thanx a lot,

Maikon

View 2 Replies View Related

Hit (cancel) But Record Still Creates?

Jul 31, 2015

When I launch my modal, I want the user to be able to 'cancel' without creating a new record. It's not doing that and creating extra 'junk' in my table. How do I prevent that?

Here's my code:
Private Sub Btn_Exception_SubModal_Click()
DoCmd.OpenForm "Frm_Exception_UpdateModal", acNormal, , acFormAdd
Forms! [Frm_Exception_UpdateModal]![clientnmbr].value = Me![clientnmbr].value
End Sub

View 6 Replies View Related

Queries :: Cancel Age Calculation Query For One Record

Mar 26, 2013

I have the following age calculation query:

Age: (Now()-[DOB])365

It works a treat! However, I do not want this to continue to calculate if the record has them as deceased - I want it to stop at their date of death.

I have a tick box that when selected indicates that this record has died, and a field where you can enter date of death.

Is there some way that via clicking this button, or by entering a date of death, I can stop the Age Query from calculating for just that relevant record, not all of them? If so, where to place the necessary VBA, etc?

View 8 Replies View Related

Cancel Button On Add New Record Form Not Working

Feb 5, 2014

I have a cancel button on an add new record form and its not working for some reason. When I press cancel it prompts if I really want to cancel and when I press yes it cancels the record creation BUT it adds a number to the recordID autonumber as if one has been created. Is there anyway to stop this? Here is my code

Option Compare Database
Private Sub Cancel_Click()
On Error GoTo Err_Cancel_Click
If Me.Dirty = True Then

[Code] .....

View 14 Replies View Related

Forms :: Open A Form For Adding Child Record Related To Highlighted Record In Subform

Oct 2, 2013

Is it possible to open a form to add a child record related to the highlighted record in the subform?

View 2 Replies View Related

Adding New Record

Jan 5, 2006

Hi,

I've a quick question. In Access, I have a form that allows user to add new record into a table. Is there anyway of finding whether the new record has successfully been inserted or added?

So i think it may be wise to have a message to notify us of whether it's inserted successfully or not.

Hope this explain clear

Thank you very much in advance for your help

View 1 Replies View Related

Adding A Record

Feb 5, 2005

Can someone please tell me why I might be adding a record everytime I open my database. I have to forms that work from querys if I open the main form all is well , if I open the other oone first and then the main form I find a record has been added. Most annoying! :(

View 1 Replies View Related

Adding A New Record

Feb 23, 2005

This may seem basic but I need some help.

I have a table of vacinations and need to add a new record every time an animal is vacinated. I have created a form with all the fields in the table in it. But when I open it it takes me to the first record. I have had to add a button to the form to add a new record. This button then takes me to a blank form where i can input data. This is very messy and not very user friendly. Any suggestions on how i can tidy this up would be appreciated greatly.

View 3 Replies View Related

Adding A New Record

Jun 15, 2006

I have looked on here for hours and cannot find anything, perhaps someone can help.
I have just converted from 97 to 2003 and now I cannot add new records to my forms. I have checked that the allowAddtions property is set to Yes but the New record icon and menu option is grayed out. I have looked through all the form settings and I can't see what it might be.

View 3 Replies View Related

Adding A Record...

Oct 5, 2006

Hi,

I have a form that has a list of textboxes linked to table properties, and a subform linked to the same table. I used the command button wizard to create an add record command, but when i click on it it comes up with:

You cant go to the specified record
You may be at the end of a record set

i have checked the properties on the forms and querys and set all data entry to yes
What should i do?

Thanks for your time

,Leon

View 9 Replies View Related

Adding A New Record

Nov 8, 2006

I have a form that has a list box with events in it. On the same form I have two combo boxes, each with the same information; officials names. I added a subform to form1 and I want this form to store and display the information that is chosen(officials and events). How do I make this happen? It seems easy, but I just can't wrap my finger around it.

View 2 Replies View Related

Adding A New Record

Apr 11, 2005

Hi all

When adding a new record via a form, how do you make the 'new' record become a 'proper' record? I.e., add the record to the table? I know it is added when you exit that particular record on the form but I would like to update the table with the details of the new record without exiting the record on the form. I had always assumed this was done with the save command but this does not work.

Any help would be appreciated.

Many thanks.

View 3 Replies View Related

Adding A New Record

May 1, 2008

heya

I'll start with the general question ... I am using code to grab a file name from a local drive and waat to create a record with the detail of the file. what code will enable me to grab the file name from a loop function and stuff the value in a table. i have tried

[code] DoCmd.GoToRecord , , acNewRec

it does not add the file name store in a variable MyName in the table tblFiles in the field txtFileName i have designated nor does the code create a new record. what am I missing - is there a good reference for this?

thanks!

View 14 Replies View Related

Event For Adding New Record

Mar 12, 2008

What is the form event for adding of new records?
I want to make some fields disappear to prevent user input when the user enter a new record.

View 2 Replies View Related

Adding Single Record

Sep 5, 2005

I have 2 tables and a query to show the details of both tables on a form for an attendance database. The idea is that whenever someone is absent they have a record created.

tbl[Staff] has the following fields StaffID,Name,Team,Job Title
tbl[Absence] has the following fields StaffID, abStartDate,abEndDate,abIssue

I can set up the query to find the member of staff by name but I want to be able to use this form to add new records to the Absence table for each individual. eg I use the query to search for "Joe Bloggs" and the form shows the details from staff table and then use the form to add details to the Absence table.

Any help would be greatly appreciated

View 2 Replies View Related

Adding Amounts Per Record

Jun 25, 2006

Hi to all!
I face the following problem: I cannot add amounts per line!
I have one table consisting of many different columns (fields), some of them having amounts. I want to update this table by doing the following:
let's say I have the following records:
1/6/2006 A 12
1/5/2006 B 20
15/6/2006 C 21
22/6/2006 D 17
25/6/2006 E 30.
I want to use a filter (e.g. the date being between 1/6/2006-30/6/2006), sort the records descending according to the amounts and then add in another field of the table A, B or C, according to whether the total amount including the specific record is above 70% of the total or above 90% of the total. In the specific example I want the following result:
25/6/2006 E 30 A
15/6/2006 C 21 A
22/6/2006 D 17 B
1/6/2006 A 12 C
Their total amount is 30+21+17+12=80 and the percentage of each record is: E:0.375 , C:0.2625 , D:0.2125 and A:0.15. Their adding percentage is
E:0.375 , E+C:0.6375 , E+C+D:0.85 and E+C+D+A:1.
How can I do that? I calculate the percentage of each record in a query, but how can I calculate their adding percentage, so that I can use an if-clause in an appending query?
Please help!!
Thanks in advance for your time

Panagiotis

View 4 Replies View Related

Adding A Record For A Combo Box

Mar 4, 2005

I have two related tables - one is study information and one is person information. For each study, a person is assigned. On my form, I have a combo box to choose a person to add to a study. This works fine when the person exists already. To add a new person, I have an "add" command button that brings up a form to add a new person to the table. Problem is when I close the form, I'd have to find the person in the combo box to add them to the study. Is there a way to add a "person record" to the person table and when I return to the study form, have that new person already associated with the study? I don't allow users to edit the person info from the study form (the same person may be associated with different studies). Any ideas to help? Thank you.

View 2 Replies View Related

Adding A Single Record

Sep 5, 2005

I have 2 tables and a query to show the details of both tables on a form for an attendance database. The idea is that whenever someone is absent they have a record created.

tbl[Staff] has the following fields StaffID,Name,Team,Job Title
tbl[Absence] has the following fields StaffID, abStartDate,abEndDate,abIssue

I can set up the query to find the member of staff by name but I want to be able to use this form to add new records to the Absence table for each individual. eg I use the query to search for "Joe Bloggs" and the form shows the details from staff table and then use the form to add details to the Absence table.

Any help would be greatly appreciated

View 2 Replies View Related

Adding A Record Problem

Mar 7, 2006

Hi, I'm fairly new to access but have some vb experience. Here's my situation.
I have 1 combo box and 1 textbox. The combo box selection determines the textbox value. I made an if statment that determines what the value of the text box will be according the the combo box selection in the afterupdate of the combo box. The problem is when I want to view another record the textbox value equals whatever the last record was. So basically the combobox selection changes all the records. Like I said I am new to access and I find this odd. Any help would be greatly appreciated.Thank you

View 2 Replies View Related

Adding A Record From A Combo Box

Jan 15, 2005

I'd like to create a combo box that is not limited to the list of records from a table, but allows the user to add to the table by typing into the combo box. I believe I write this code in the "after Update" event, but I'm not sure of the syntax. Can someone help?

The combo box is simply displaying the records from another table...so the code would add a record.

Thanks much!

View 7 Replies View Related

Adding A Record With New Primary Key

Dec 19, 2011

I am creating a form to add records to my database. I have created a primary key that is not autonumber. When adding a new record, I want the form to put a primary key default value of the next number in sequence. How do I do this?

View 2 Replies View Related

Adding A Record Through Combo Box

Mar 13, 2013

I would like to add a value that i choose from a combo box to a table by clicking a button after selecting it from the combo box, and i do not know how to do it?

View 11 Replies View Related

Adding A New Record Using With AllowAdditions Set To False?

Jul 17, 2005

Hi,

Is it possible to add a new record thorough VBA (for a command button) with the AllowAdditions property set to false?

I only want new records created if this command button is pressed.

TIA!

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved