Modules & VBA :: Unable To Create Duplicate Records On A Subform?
Nov 20, 2013
I am working with a sub-form where once a staff member enters there sub measure I would want to create a duplicate of that record. The problem I am having is that once you enter the sub-form and click the duplicate button it creates a duplicate of the record selected but overwrites the first record in the table. I want it to create a new SubMeasure Number which is the primary key and assigns the record the next available number.
Also if I try to add another record after one has been added I get runtime error "3021" - No current record. I would have to close the form and reopen for it to be able to add again.
I have attached the code below:
Private Sub cmdDuplicate_Click()Dim dbs As DAO.Database, Rst As DAO.Recordset
Dim F As Form
'Return Database variable pointing to current database
Set dbs = CurrentDb
Set Rst = Me.RecordsetClone
[code]....
View Replies
ADVERTISEMENT
Nov 29, 2013
I am trying to create duplicate records from a main form frmManagers which has a subform frmSubMeasure. I have placed the duplicate button on the main form. It creates a duplicate of the main form data and gives me the option to add new record to the sub. I want the duplicate to be created on the sub form for me to just edit the scores.
I don't know how to pass the sub form data to be duplicated I thought the append query which I used would update the tblSubMeasure table which created the subform frmSubMeasure.
In the sub the append query do update the form with the new MeasureID from the mainform and the form is available to enter new data. I want the subform data to be duplicated as well
In the query I included all the fields from the tblSubMeasure table and this is appended to the same table tblSubMeasure and I place a tag on the MeasureID using "[Forms]![frmManagers].[Tag]"
Code:
Private Sub btnDuplicate_Click()
Dim dbs As DAO.Database, Rst As DAO.Recordset
Dim F As Form
'Return Database variable pointing to current database.
Set dbs = CurrentDb
Set Rst = Me.RecordsetClone
[Code] .....
View 1 Replies
View Related
Jun 13, 2013
I have a code that works great from the parent form but I decided to change the format and call it from a lostfocus event in the subform instead. Now I keep getting error 3314:"You must enter a value in the tbGuests.LastName field".
The code should copy the parent form fields and create x number of duplicate records according to a field on sub-form. It then runs an append query to add the information from the subform.
Code:
Private Sub GuestsInParty_LostFocus()
Dim partymsg As Integer
Dim dbs As dao.Database, rst As dao.Recordset
Dim F As Form
Dim intHowMany As Integer
Dim intCounter As Integer
[code]....
View 1 Replies
View Related
Nov 16, 2013
I have created three forms using three tables tblUser, tlbMeasure and tblSubMeasure. The tblUser is linked to the tblMeasure table via UserLogin and tblMeasure is linked to tblSubMeasure via MeasureID. The forms are created with frmMainMeasure being the main form and frmMeasure6 a subform and frmSubMeasure a sub with frmMeasure6.
I want to be able to add sub measures that will be linked to each MeasureID and each MeasureID link to each user via UserloginID. The forms load the data in the sub forms but when I try to add sub measures using a button I added on the frmMeasures6. The button works when I try work on the form fine but when I try via the main form I am not able to add or view other records within the table.
When I click the Add button I want to be able to load back the same MeasureID number in fmrSubMeasure to ensure that it is linked to the same measure and the MeasureID is linked to the same UsrrLoginID.
The code is included below and I've attached the file as well.
Private Sub cmdAdd_Click()
If Me!frmSubMeasure.Form.Dirty = False Then
End If
Me!frmSubMeasure.SetFocus
DoCmd.GoToRecord , , acNewRec
[Code] ....
View 1 Replies
View Related
Jun 27, 2014
I have almost no experience of VBA outside of working a little with codes generated for me like docmd etc.
I am trying to create a database for resourcing staff.
I have a form where the user inputs a start date and an end date which updates a table.
I have a query that works out the number of working days between those dates.
I have a table with all the working dates between now and 2016
I want to put a duplicate record button on the form (I can do that bit)
The tricky part is I want it to create a new record for each date in the dates table between the start and end dates.
Example 23/06/2014-18/07/2014 = 20 working days. I want to end up with 20 records with start dates as below and the same end date.
23/06/2014, 24/06/2014,25/06/2014,26/06/2014,27/06/2014,30/06/2014,01/07/2014,02/07/2014,03/07/2014,04/06/2014,07/07/2014 etc up to 18/07
View 9 Replies
View Related
May 22, 2013
I am trying to create a database by compiling records from multiple excel sheets. however, since most of the clients still uses the excel sheets to enter records, I am thinking if it's possible to create a linked table in access from these excel sheets that are hosted on an online server.
also is it possible to merge multiple linked tables together? if they have the same field range, so they will append when the linked tables gets updated.
View 3 Replies
View Related
Sep 19, 2013
I have tried to create an MDE database and receive the message "Microsoft Access was unable to create an MDE database" I deleted all unnecessary tables, queries, forms and reports and still receive this message.
how to fix this problem in MsAccess 2003?
View 6 Replies
View Related
Mar 21, 2014
See attached picture where I am stuck at?
I have a table that holds UK Postcodes and a customer table that holds customers.
I am trying to create a relationship between the 2 so when I enter a postcode in the customer table this is then related to the postcode table.
The main problem I have is that there is a lot of duplicate postcodes in postcode table so the primary key is simply a number as you will see in the picture.
View 2 Replies
View Related
May 29, 2014
In my simple database (attached), I need to mass duplicate Tasks and their Notes.
I have three tables: tbTasks (PK: Task_ID), tbNotes (PK: Note_ID), jtbTaskNotes (FKs: Task_ID and Note_ID). jtbTaskNotes is my many-to-many junction table that ties Tasks to Notes.
The main form (fmTasks), bound to tbTasks, has a subform (sbfm_TaskNotes) that displays notes associated with each Task. On themain form,you select which Tasks you want duplicated via a checkbox. The append query (quCopyTasks) will duplicate all tasks that have the checkbox checked. All good there. However, I can't figure out how to also duplicate each task's Notes.
I found Allen Browne's solution [URL] ....., but that only handles duplication of one record at a time, whereas I need to duplicate many records at a time (sometimes 10+ records). How do I go about duplicating multiple Tasks and their associated Notes?
Before you ask "why are you duplicating records?": There are times when tasks need to be re-accomplished and therefore need to have a new record. It's easier to duplicate records than it is to hand-jam everything again.
View 5 Replies
View Related
Jan 13, 2015
I'm using form with subform. Main form header contain a combobox. I need to check the combobox is null or not before update a subform filed. If combobox is null then its back to Main form combobox from subform. The code below that I'm trying to:
Code:
Private Sub AssignTo_BeforeUpdate(Cancel As Integer)
If IsNull(Forms!frmDepartmentReview!cboDepartment) Then
MsgBox "You must select Department first", vbInformation
Forms![frmDepartmentReview]![cboDepartment].SetFocus
End If
End Sub
Then I'm getting 2110 run time error
Access can't move the focus to the control cboDepartment.
View 4 Replies
View Related
Jul 23, 2015
I was updating my records by filling a form and entering the data's into a table but all of a sudden i couldn't add data to form and table..
View 9 Replies
View Related
Jun 25, 2015
How to duplicate records in SubForm, i have created a form (transmittal) with a subform that contains all items listed:
Master Field : Transmittal No
Child Fields: IDTransmittalNumber
There is a button that allows me to duplicate form , however when i change the Transmittal no in the main form it automatically deletes all data in subform since they are both linked by that field..
View 8 Replies
View Related
Aug 29, 2013
I have a form that uses Table A as a record source and has a subform that uses Table B as a record source. There is a one to many relationship between Table A (one) and Table B (many).The user opens the form to a set record, then uses the subform to create a new record in Table B.
This works perfectly and I can do everything I want. But sometimes the subform creates a blank entry in Table B before I enter any data. Then, once I start entering data, it creates another record in which it stores the data that I am entering.The result is two records: One that only has the date of the record's creation (I set that to be automatic upon creating a new record) and the primary key that links Table B to Table A. A second one is the "true" record, the one which stores all of the data that I am entering.
It won't happen for 10 records or something and there is no apparent pattern. In case it makes a difference, the form is set to open as the subform as the focus.
View 14 Replies
View Related
Mar 9, 2015
I currently have a report which contains a subform. The master/child fields used to link them are called 'StudentID'.
In the table on which the subform is based, it is possible for multiple records to be associated with a single StudentID: in this case, the subform shows the locations where a student is studying, therefore if a student is based in three different locations the subform will display all three.
This seems to be resulting, when I run the master report, in three identical iterations of the same report being displayed (at least this is the only reason i can see why these duplicates would be displayed; it doesn't happen if a student only has one record in the subform).
Clearly, as a single instance of the report shows all three records in the subform anyway, I don't want to be seeing these duplicates.
View 5 Replies
View Related
Dec 2, 2013
I'm trying to search a for string within a subform to find information stored on the mainform to which the particular subform belongs.
The problem is that the subform is generated from a query which uses a number from the main form to generate.
So the subform record is only generated when the correct mainform record associated with it is loaded.
Now to solve my problem I've made a new query that brings up ALL the results that could be generated by the main form and from that I can search to find my search term I'm after and read off the ID number to tie it back to the mainform.
But all of this is done manually, I want a way to do all this using VBA in a way that the user can't edit any records as they are doing it.
View 3 Replies
View Related
Jul 31, 2014
Why I am not able to get all records by excluding the Numrows argument in the getrows method?
Sub Test2()
Dim myrset As Recordset
Set myrset = CurrentDb.OpenRecordset("SELECT * FROM Holidays;")
myrset.MoveLast
myrset.MoveFirst
MsgBox Excel.Application.WorksheetFunction.Networkdays(#8/1/2014#, #8/31/2014#, myrset.GetRows(myrset.RecordCount))
MsgBox Excel.Application.WorksheetFunction.Networkdays(#8/1/2014#, #8/31/2014#, myrset.GetRows())
End Sub
Second MessageBox is giving a wrong value.
Is it a mandatory one? Or Do I have to do some ritual like (Movelast) before that?
(Holidays table is just having the values in the array only ie. #08/15/2014# and #08/29/2014#)
View 10 Replies
View Related
Jun 4, 2013
I'm trying to duplicate the records in a subform to a new form but keep getting a too few parameters error.
Code:
strSql = "INSERT INTO [OrderDetailT] ( OrderID, ProductID, Quantity, DiscountPercentage ) " & _
"SELECT " & lngID & " As NewOrderID, ProductID, Quantity, DiscountPercentage " & _
"FROM [OrderDetailT] WHERE OrderNumber = " & Me.OrderNumber & ";"
The debug.print comes out as below:
INSERT INTO [OrderDetailT] ( OrderID, ProductID, Quantity, DiscountPercentage ) SELECT 49 As NewOrderID, ProductID, Quantity, DiscountPercentage FROM [OrderDetailT] WHERE OrderT!OrderNumber = 11;
View 4 Replies
View Related
Jun 18, 2014
I have an "Returns" master form that contains two subforms. The subforms contain items that we are returning back into our inventory. The underlying queries in each subform show only those records where the "Return Date" is null. The query(s) works fine, except that if there are 3 items that need to be returned there are 3 records that show in the master Returns form. I tried the Totals option in the query but the I need that Return Date on the subform. I only want one Returns master form to show the 3 records (not 3 records of the same master form).
View 5 Replies
View Related
Apr 11, 2006
I have searched, but found no reference to my exact question. I have a list of drivers I need to create a checklist for each day. The Parent form is the day and the subform is the list of drivers. What I would like to do is have a command button automatically enter all the drivers that are active (denoted by a chechbox) into the tabular subform.
View 14 Replies
View Related
Aug 12, 2007
Hello
there is a field in my form named "numphotos" and I write the number of photos than that folder contains.
I have a subform in that main form named "descriptions", here I describe, one for one, all photos of that folder.
Itsnīt a problem if the folder contains a few photos, but I have folders that have even 100 photos :confused: then I must to create 100 records in my subform :eek:
I would like than Access create those records automatically according to the number of photos that I indicate at the field numphotos.
My example in photo: http://farm2.static.flickr.com/1141/1093088982_a084bff95f_o.jpg
I only would desire that Access create that many lines to me as I have written on "numphotos". I would write the rest of the information (photographer and description)
is it possible?
thanx!!
windowsXP
access 2007
View 5 Replies
View Related
May 17, 2005
hi,
I am trying to write a training register DB for my department basically:
There are three tables: trainees, training sessions, and trainees on courses.
The training sessions will be mapped out in advance: so that's easy we will plug in the training dates when necessary.
the tricky bit is the booking form for trainees. I'd like a form/subform where the trianing session info is at the top and the subform lists trainess for that day.
Now here's the rub. we may not have the trainee's name in our database already so I created a combo box with the all the known trainees. This way if they exist their details pop up and we have a new "trainee on course" record for them.
So what I need is a macro or some code that will check whether they exist and if not create a new traineee record and then allow us to fill out the booking form. Perhaps I'm rusty and not thinking this through properly.
I'[ve attactched the db in case anyone needs a visual. I'd be grateful for any suggestions
The problem is when we get a new trainee with no history we cant create them. either I have
View 3 Replies
View Related
Jun 29, 2013
What would be the Access 2007 VBA code for checking for duplicate records?
View 14 Replies
View Related
Jun 21, 2013
I have a table called tblCompanies in which I have a field called CompanyName that is indexed set to "no duplicates". However, I want access to be able to pick out probable duplicates instead of only exact duplicates.
So, for example, if "Butter Fingers" is entered and "Butterfingers" is already in the database, I want access to prevent the new record from being created.
The code I found on MS Developer's reference only prevents exact duplicates which seems pointless since this can be done just as effectively on the table level using an index.
Anyway, here is the code:
Private Sub CompanyName_BeforeUpdate(Cancel As Integer)
If (Not IsNull(DLookup("[CompanyName]", _
"tblCompanies", "[CompanyName] ='" _
& Me!CompanyName & "'"))) Then
MsgBox "Company has already been entered in the database."
Cancel = True
Me!CompanyName.Undo
End If
End Sub
Can it somehow be modified to do what I want it to do?
View 8 Replies
View Related
Jun 12, 2014
I have a table which has duplicate records so I want to write down the code so that when the user click on a button then it should remove the duplicate records from the table.
View 2 Replies
View Related
Apr 14, 2014
I have a table it contains a list of opening and closing values along with a date and a couple control fields. What I would like to do is duplicate a few fields from records that meet a criteria onto the same table. After that is done there will be a few updates on the new records. Looking at it, it would be: 'duplicate' where field2 <> 0 and field5 = No and field6 = Yes. All other fields on the newly created records would be their default values.
View 7 Replies
View Related
Oct 21, 2014
How to give a VBA code for duplicate records is without entry in Subform datasheet. I just used in the screenshot code but that is not working properly. how to change a vba code for without entry duplicate names.
View 11 Replies
View Related