Create New Record With Form
How do I create a new record (in the table to which the form is bound) automatically if, when the form opens, there is no record in the table that meets the criteria in the form filter?
Thanks!
View Complete Forum Thread with Replies
Related Forum Messages:
Create Record With VBA, Edit With Form
I have the following code on a combo box in a form that creates a new record in the table Products if it doesn't already exist: Code:Private Sub comProduct_NotInList(NewData As String, Response As Integer) Dim strSQL As String 'Exit this sub if the combo box is cleared If NewData = "" Then Exit Sub strSQL = "Insert Into Products ([Product]) " & _"values ('" & NewData & "');" CurrentDb.Execute strSQL, dbFailOnError Response = acDataErrAdded End Sub It creates a new record and inputs the appropriate value into the Product field, however then it goes to the next record and when I try to edit other fields, it does so on a new record. So, for example, I wanted to set the Product field to ProductA and the Brand field to BrandB and the Size field to 200, it produces two separate records like this (code box used for formatting): Code:Product | Brand | Size |ProductA BrandB 200
View Replies !
Linking Form To Search Or Create New Record
I have uploaded an example of my database As you can see there are two tables and two forms. What i want is for a user to view or enter data for a record on the first form. And then when they are done they click the button to open up form2. What i want to happen is for the company name/id from the record in form1 to be searched for when form2 opens and to display only the data for that record when opened. If no data exists for that record in form2/table2 then for it too create a record for that company when form2 is opened from form1 hope this makes sense and you can help Please note this is just an example so if there is wrong naming conventions and such please ignore if there is as i just wanted to display quickly what i want to acheive
View Replies !
Simple: Create A New Record, Update Old Form
Hi... I searched quick, didn't find anythign, but you guys are so responsive... :D Question: Part 1. On TimeSheet form, I want to click to "create new job", and the Jobs Form opens, at a new record. Currently it opens at record 1. Part 2. I foresee that when I return from the modal job form, the old form (timesheet) would not have updated the combobox to show the jobname I just entered. I guess this is what subforms are, because I keep reading about them, but dunno what they are. Thanks -Reenen
View Replies !
Create New Record On Form And Subform Simultaneously
When I click the new record command button which I created I get a new record, but the form has a subform and this starts with no records. How can I program this button to not only create a new record and the form to which it relates, but also to create a new record on the subform contained within it as well??
View Replies !
Create A New Record, Opening A Form Based On The Key Field
I seem to need some help! I have a table with customer information in it ie: name, vehicle, (Key=Id number)... it is the master link to the repair table ie: mileage, (Key=ROnumber), and repair data.. these two work together beautifull now I need to add another table, a check sheet for checking over a vehicle. I create the table and the form however I cannot open a new form with the ROnumber from the second already open form into the newly open form. (the second form is based on a Query, and I have tried changing it to a SQL statement both with no luck) is there an example of what I need to be doing to link the ROnumber to the ROnumber in the new form, or create the ROnumber so it will add the data in the linked table? I need this to open using a button on the open repair form David
View Replies !
Record Create Date?
I think I know the answer to this, but thought I'd see if anyone had any ideas... I was asked if there was any way to know when a record was created in the database. When the table for these records was created, a field for "Enter Date" (i.e. the date the record was enterd into / created in the database) was not a part of the structure. I know that for going forward, we can create this field in the table and have it populate with Date() behind the scenes so we can track the actual enter date. But, for the records that are already there, is there anything that Access keeps somewhere as to when the record was created in the table? Thanks in advance~
View Replies !
Create New Record In 2 Tables At Once
hi everyone, i think this must be easy but im new and despite reading lots just cant figure it out. i have 2 tables job details: autonumber customer location time picking list: autonumber, equipment1 equipment2 equipment3 both the autonumber are primary and linked in a relationship. when i create a new record in the job details table i need it to automatically create the coresponding blank line in the picking list table with the same number. If I enter something in the picking list table then it creates the matching number and everything is ok but if i dont then it throws my numbers out. any idea how to get it to do what i need, thanks
View Replies !
Create Record If None Exists
I have a table (tblSales) with these fields (RecDate, Code, Type, OrderCount). I also have a linked table (lnkSales) with these fields. Daily I append the data from the lnkSales to tblSales. The tblSales table must have a record for each code daily. These are the codes (01,02,05,07,09,10,15). I need to automatically add a record for each code that wasn't appended. For example, lnkSales contains: 03/22/06 01 Mc 3 03/22/06 02 Mc 1 03/22/06 05 Mc 1 03/22/06 07 Mc 2 03/22/06 10 Mc 1 When appended to tblSales there is no record for code 09 or 15. I need to add these records to tblSales 03/22/06 09 Mc 0 03/22/06 15 Mc 0 Can someone explain the best way to accomplish this? Thanks.
View Replies !
Copy And Create A New Record
I have a program that you can search all or a specific record. Once you find the record, you can double click on it and another form will open up with only that record's information. What I need is to have a button that will copy this record's name, address, phone number, contact info, and etc --> and create a new record with a new Record Number using the current record. This will allow the user to avoid entering in the same information again. For confirmation purposes, I would like to have a SAVE button to verify and save to the DB. Does anyone have any inputs on how I can do this? If you would like to see the program, please let me know. Thanks in advance for all your help and suggestions!
View Replies !
Create Record If None Exists
I have a table (tblSales) with these fields (RecDate, Code, Type, OrderCount). I also have a linked table (lnkSales) with these fields. Daily I append the data from the lnkSales to tblSales. The tblSales table must have a record for each code daily. These are the codes (01,02,05,07,09,10,15). I need to automatically add a record for each code that wasn't appended. For example, lnkSales contains: 03/22/06 01 Mc 3 03/22/06 02 Mc 1 03/22/06 05 Mc 1 03/22/06 07 Mc 2 03/22/06 10 Mc 1 When appended to tblSales there is no record for code 09 or 15. I need to add these records to tblSales 03/22/06 09 Mc 0 03/22/06 15 Mc 0 Can someone explain the best way to accomplish this? Thanks.
View Replies !
Link To Create New Record
I am new to using MS Access and I am having a difficult time trying to do one particular thing. What I am trying to do is represented in the Contacts database template in Access 2007. When that database is opened, there is a link labeled as New displayed on the table that opens a form to enter a new record. I cannot figure out how to do that, can anyone help? Also, is there a way to automatically open a particular form when the database is opened?
View Replies !
Auto-create Record In A Table
I need to make Access automatically create new records in a table for me. Just for example:- Table #1 has 2 fields PersonID (autonumber) PersonData (text) Table #2 has 3 fields ID (autonumber) PersonID (number) MoreData (text) The database user creates a new record in Table #1 using a form. I need the database to automatically create a field in Table #2 and fill in PersonID, taking the value from the autonumber field of the same name in Table #1. The MoreData field can be left blank. I don't need that filled in automatically. I just need a new record to be created automatically in table2 with the PersonID field filled in with the most recently created autonumber. Help massively appreciated.
View Replies !
Recall - Create New Record In Datasheet
I have a main form called FrmCalls with a button on, which when pressed brings up a pop up form called FrmSurround, within which is a subform in datasheet format called FrmContacts. This has 3 fields within it. I want the system to tak a value from Frmcalls (numeric value) when the button is pressed and place it as a new record in one of the fields on the datasheet (FrmContacts). Any ideas anyone? Please, Recall.
View Replies !
Create New Record From Multiple Controls
Hello, I have two controls on my form that I want to reference in an append query to create a new record. The first is a text box, the second is a combobox that is populated with all of the dates associated with the text box. The selection of a date updates a subform based off of a hidden column (chart ID, an autonumber field based on combinations of record numbers and visit dates) in the same combobox. I would like the user to be able to enter a new date and create a new record that would contain the next autonumber in association with the new date and the record number from the text box control. I have tried using an append query with the following SQL, but I consistently get errors referring to "type mismatch." Any help would be greatly appreciated; thanks in advance. Code:Private Sub cboDOVSearchChart_NotInList(NewData As String, Response AsInteger)Dim ans As Variantans = MsgBox("The date you entered was not found. Do you want to add a newdate?", _vbYesNo, "Add New Date?")If ans = vbNo ThenResponse = acDataErrContinueMe.cboDOVSearchChart = NullDoCmd.GoToControl "cboDOVSearchChart"GoTo exit_itEnd If' add dateIf ans = vbYes Then Dim strSQL As String strSQL = "INSERT INTO Patient_Visits ([Medical Record Number], " _ & "[Date of Visit]) " _ & "Values (" & Me.[txtChartMR] & ", " _ & "#" & CDate(NewData) & "#)" 'this line has the arrow on debug CurrentDb.Execute strSQL Me.cboDOVSearchChart.Requery Me.cboDOVSearchChart = NewData Call cboDOVSearchChart_AfterUpdateEnd Ifexit_it:End Sub
View Replies !
Data Entry Interface (Create New Record) Help
Could anyone of you give me some sugguestions on designing a nice/efficent Data Entry interface (Form design) for adding new records?: I have bound a Form with a table and linked all the textbox with the relevant fields in the table. I created a add new record button through the wizard provided by MS-Access as: DoCmd.GoToRecord,, acNewRec. While, each time when I opened that Data Entry Interface, the current always pointed to the first one rather than leaving the blank field for data entry. Even I changed the value in those textbox, the system didn't create a new record in the table at all, only modifying the first record. I know how to write the VBA code to open table and add new records by retrieving data from the Form interface, but I wonder whether there is more efficent solution by combining the default function/facilities from MS-Access itself and some VBA code. Also, it can have some validation before storing data into the tables. Many Thanks
View Replies !
How To Create A Message Box Indicating Record Is Locked?
I have done some serious searching and have discovered that many others have posted this question, but I couldn't find any satisfactory answers. I have a FE/BE Access 2000 database in a multi-user environment. I have my default record locking set to "No Locks" (optimistic), but for unknown reasons, some records still lock. The records are viewed via a form, which is also set to "No Locks." We only have about 20 users, so it is rare that two people actually have the same record open at the same time. It seems to be that whole groups of records lock sometimes, despite the fact that I'm using optimistic record locking. Usually if you wait 15-20 minutes it is unlocked. If someone can explain this I would be overjoyed. But, I can deal with the record locking. The problem is that users have no idea why they can't update a record and no matter how many times I tell them to wait 15 minutes they still come crying to me every time. So, I want to make a message box pop up when they try to update the record that states something like this: "The record is currently locked. Please try again in 15-20 minutes." If someone could offer some code options and explain where it needs to go (form load, open, etc.) I would be eternally grateful. Thank you!
View Replies !
Custom Error Message On Create New Record
I have created a command button through the wizard that is basically: DoCmd.GoToRecord , , acNewRec Well, it puts all this code in the event: Private Sub NewVerification_Click() On Error GoTo Err_NewVerification_Click DoCmd.GoToRecord , , acNewRec InboundQuestions!Page1.SetFocus VerificationNo.SetFocus Exit_NewVerification_Click: Exit Sub Err_NewVerification_Click: MsgBox Err.Description Resume Exit_NewVerification_Click End Sub Well, my PK field is one users enter in manually (please don't ask why). What I need is something that checks to see if the number in that field is a duplicate key, so I can tell users via msgbox "Duplicate Number, try again". Right now, it's not that descriptive, it says "You can't go to the specified record". I guess all i need is an If statment, but I don't know the code that checks to see if [field1]'s value has already been used in my table. Any ideas?
View Replies !
Append Query Key Violation (as Used In Create Similar Record)
I have a database of Assessments, each record having multiple subforms. I am working on a button, which creates a "similar" (same) assessment, copying over all the subform records/selections. So, after I actually insert a new assessment, pasting all the values from the original Assessment: DoCmd.RunCommand acCmdSelectRecord DoCmd.RunCommand acCmdSaveRecord DoCmd.RunCommand acCmdCopy DoCmd.RunCommand acCmdPasteAppend I need to copy over subform contents, for which I use an Append Query (actually, I use its SQL in VBA code to pass it the right parameters). Now, naturally, I ran into Key Violations, because taking 50 sub-records from the original they would have their own AutoNumber Keys (ID's) and I can't append them into the same table. My question: how do I copy over the same records (appending FROM and TO the same table) but cause the table to insert AutoNumbers for the records being appended? Thanks!
View Replies !
Create New Record & Pass Autonumber To Separate Table
I have a form, frmSub, that contains the combo box comProducts. I also have two tables, Products and PurchaseDetail. Both tables have the field ProductID. I want comProducts to create a new record in the Products table, using the input in a field called Product and then to use the value of ProductID to create a new record in the PurchaseDetail table. Ie, so the PurchaseDetail table has a record that links to another record in the Products table via the feild ProductID. I hope I was semi-clear.
View Replies !
|