Modules & VBA :: Unable To Add Records To Subform
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 Replies
ADVERTISEMENT
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 4 Replies
View Related
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
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
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 16, 2014
I have a form which has a subform that holds records from a table. When in the table i can move through the records with my up and down arrows but when I am in the subform i can not move in the same manner with up and down arrows. What needs to be done on subform to allow user to move through records using up and down arrows.
View 1 Replies
View Related
Mar 5, 2015
I have a form with a subform. I would like a control in my parent form to uncheck a checkbox control in my subform when that field value is deleted . I can get that to work if there is only one record in my subform but it doesn't uncheck the rest. how to I reference all the records in my subform so all of them will uncheck when I delete that field value?
View 2 Replies
View Related
Sep 9, 2013
I have button the when pressed will insert a record (via an insert into query) to the frmMain and several records to the frmSub.The problem is when a new record is created in the main form the auto number primary key advances. This is fine however the linked Child field which is a foreign key of the main form is not added and the value is blank. I thought this would happen automatically and the Master field would force the child field to be update but this is not happening.Do I have to determine the max number used in the auto number then add 1 to it?
View 7 Replies
View Related
Feb 23, 2015
I am trying to add a save/close button to a form that will only close if certain conditions are met and if they arnt then display a message box.I got the basics on how to save and close the form, do a simple if statement and display the message I want but the problem im running into is my subform can have multiple records and of those records each records status is set by 3 different checkboxes. I need all of those records status to be same when the form is closed.
if I do an if statement like
If Me!frmDataform1subform.Form!StatusID.Value = 1 then
docmd....
then all it looks at is the first record, how do I get my if statement to look at all the records in the subform?
View 2 Replies
View Related
Sep 12, 2013
i want to Count recrods by a pressing a button from a subform.
After counting the records from the subform, it should compare the amount of the records with a number.
The user can put in the number.
The field for the number is called number.
The button is in the form.
I've created the following code.
The Name of the subform ist Abfrage_Vergutungssatze_Unterformular
Code:
If DCount("*", Me.Abfrage_Vergutungssazte_Unterformular) > Me.number + 1 Then
MsgBox "Please recheck!"
I've get an error.
error message: errors when compiling
View 4 Replies
View Related
Sep 12, 2012
There are 2 levels of forms, the main parent form is called INSPECTION. Then there are two subforms: TESTRESULTS and addTESTRESULTS.
the form TESTRESULTS is linked to the TESTRESULTS query "QTESTRESULTS2". This query looks at two hidden fields on INSPECTION called FILE and REPORT NO. The query finds all fields inside of TESTRESULTS that match the two criteria. This works fine. The form TESTRESULTS is linked to the QTESTRESULTS2 query as direct data source link. This works fine.
a temporary table has been setup to append test results to TESTRESULT table. This works fine. What doesn't work fine is updating the subform TESTRESULTS when needed. I want it so that the welder enters his information, clicks save, the info gets appended to TESTRESULTS table and instantly updates on the form for them to verify.
[inside subroutine for saving a record] all efforts at accessing this form have failed. I've tried !form!subform!requery, it has failed, I've tried making dummy fields inside the form and accessing them and that has failed, I've tried .setfocus on the form and that has failed, each time the compiler tells me 'unknown field', when in fact I'm trying to hit the form itself.
Its worth mentioning that I've set events [on this form for any kind of update event including mouse click] to Me.requery for this form when you click on it, it updates, but I need to automate this somehow, and the form just seems untouchable via VBA.
View 11 Replies
View Related
May 26, 2015
I am working with a database that deals with trailers. What is happening is a salesman takes an order for a make and model for a trailer for a customer. The customer can then add some customization to the trailer such as more tail lights or tie down straps. They add the customization on a form called frmCustomQuote. On frmCustomQuote there is a subform called sfQuoteConfigs. On sfQuoteConfigs there is fields such as category and sub catergory that get populated bases on what was selected.
On frmCustomQuote there is a button called "Copy Quote" this will allow the salesman to make an exact copy of the trailer and customization. The quotes are held in a table called tblQuotes and the customization is held in tbQuoteConfigs. Now my problem is when I click on Copy Quote it only copies the first record into tbQuoteConfigs. I can't figure out a way to tell my code to move to the next record within sfQuoteConfigs.
My code:
Code:
Option Compare Database
Option Explicit
'Setup ADODB connection to the tblQuotes
Dim adoQuotesCustomQuote As New ADODB.Recordset
'setup ADODB connection to the tbQuoteConfigs
Dim adoQuoteConfigsCustom As New ADODB.Recordset
'Dim the Variables
[code]....
View 4 Replies
View Related
Aug 13, 2014
I have a form that contains a subform. I want to make a button that on click updates all the records listed in the subform. This is the best I came up with.
Dim rs As DAO.Recordset
Set rs = Me.SubList_for_Billing_Center_Form.Form.RecordsetC lone
With rs
.MoveFirst
Do While Not .EOF
.Edit
UPDATE Billing SET Billing.Billing_Declined = True, Billing.Billing_Declined_Date = Date()
[Code] ....
View 1 Replies
View Related
Jun 3, 2014
I have got a received form that has 2 subforms.
The main form is based on Received Table
The 1st subform is based on a query that shows the order detail and how many units are outstanding.
The 2nd subform is based on a receivedDetail table. so will have a list of items with the original order qty, and the qty still outstanding.
When the main form loads i want it to create new records into the 2nd subform based on the 1st Subform.
so the 1st and 2nd subform run parallel with each other and appear to be as one to the user.
both subforms are continuous style.
Code:
Private Sub Form_Load()
With Me.Form.RecordsetClone
Do While Not .EOF
.AddNew
!UserFK = Forms!frmReceive!cbxUsername
[Code] ....
View 3 Replies
View Related
May 23, 2014
Im v new to VBA and been having trouble getting the following code to loop through the records in my subform:
Private Sub cmdComplete_Call_Click()
Dim rs As dao.Recordset
Set rs = Me.fsub_Call_Off_Quantities.Form.RecordsetClone
rs.MoveFirst
[code]....
It only seems to update the first records txtQuantity_Called_Off value. I have tried all the 'looping' code variations i can find and they all seem to only update the first .
View 6 Replies
View Related
May 31, 2006
I have a form/subform that I want to link together using a memo column, yet when I try Access tells me that the column datatypes are incompatible. I've even tried making both the form's and subform's recordsource be the same table. Any idea how I can do this?
View 6 Replies
View Related
Sep 1, 2006
When I try to edit fields in a subform the cursor always jumps to the first record's first field with a tab stop. I can not complete the modification and the cursor jumps back to the first record. When on the first record and on any other field the cursor will jump to the first field with tab stop.
I use Access 2003.
View 1 Replies
View Related
May 30, 2015
I am trying to close a form with a subform.
I enter data in the main form and then the subform.
The main form has a save btn with an on click event which includes at the end of code
If Me.Dirty then
Me.Dirty = false
DoCmd.Close
DoCmd.OpenForm "FormName"
However the Form will only close and open the required form if I remove the two "Dirty" Code lines.
I am obviously trying to ensure that the data is saved on both the main and subforms using the If Me.Dirty......code
View 7 Replies
View Related
Jun 28, 2013
I have a form that displays an updatable subform. The main form has search fields and a search button that when clicked will reset the record source of the subform and then do a refresh. The problem is that after the search the subform stops becomes locked. Here is the code:-
Me!sbfDepartmentSub.Form.RecordSource = MySQL
Me.Refresh
I have tried Me.Requery also.
View 10 Replies
View Related
Apr 7, 2006
Hiya
I have created a query (Weekend) from 2 other querys (BCV & Daily Sales). The BCV & Daily Sales queries work fine but when they are added together I am unable to add new records. I only have 1 line of data that can not be updated.
I thought it was a relationship problem and have been and double checked all the relationships but can't see an error.
Heres a screen shot if it will help!
Thanks in advance
http://img364.imageshack.us/img364/2458/clipboard022zc.jpg
View 5 Replies
View Related
Jun 20, 2013
I have a sub form that allows users to add staff to a project team, once added it populates a table which updates the subform showing the selected employee. I am trying to enable a delete function that allows users to remove an employee from the project team in the subform showing selected staff. Here is the code I have so far, but it doesn't work;
Code:
Private Sub Command4_Click()
Dim dbs As Database
Dim rs As Recordset
Dim sqlstr As String
Set dbs = CurrentDb
sqlstr = "DELETE tbl_CapexStaff.* FROM tbl_CapexStaff WHERE CAP_ID = Forms!frm_Switchboard.CAP_Live"
dbs.Execute (sqlstr)
End Sub
View 4 Replies
View Related
Aug 26, 2013
My subform consists of a list of tasks that are waiting to be verified. in order to verify tasks, the user scrolls through the list of tasks and checks a checkbox (discrepancyverified) on each record they wish to verify. After the user has finished checking all the records they wish to verify, they click a verify button on the main form which should then go back through each record and update the verifieddate value of any that are checked to today.
This is what I have so far:
Code:
Private Sub Command19_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim ctl As Control
Dim varItem As Variant
[code]...
View 3 Replies
View Related
Jun 5, 2013
I'm having some problems with VBA code I'm writing that references a subform. I'm pretty new to VBA and am not sure what the problem could be. The parent form (TrackingForm) tracks dates different tasks were completed. The subform (Child2) tracks exceptions that also need to be marked completed. I need ALL dates to be marked as completed before the entire tracking record can be marked as completed.
I have the following code entered into the OnFocus event of the tracking records Me.Completed_Date field:
Private Sub Completed_Date_GotFocus()
If IsNull(Closing_Date) Or IsNull(Package_Received) _
Or IsNull(Upload_By) Or IsNull(Initial_Review_Date) _
Or IsNull(Me.Child2.Form![Date Exception Completed]) Then
Me.Completed_Date.Locked = True
MsgBox "Completed Date cannot be entered - outstanding items.", vbOKOnly, "Warning!"
Else: Me.Completed_Date.Locked = False
End If
End Sub
What ends up happening is that, if there is more than one exception record on Child2, the code only seems to care if one of the records (usually the first record) has something entered in the [Date Exception Completed] field. I can't seem to make it look at any successive records in Child2 to ensure they are also completed prior to unlocking the Me.Date_Completed field. I have googled this extensively over the last day and the only response that seems to recur involves using a Recordset function that I have never used and am unsure how to.
View 4 Replies
View Related
May 4, 2015
I have a main form that controls 2 subforms. sbfActiveProjects displays a list of records that have not been flagged as complete. Upon clicking on a record in sbfActiveProjects, the details of that record show up in sbfProject. This functionality works great, except when I try to create a new record. The code works fine for getting a new record, however once I run the command I lose my ability to navigate to other active records.
Code:
Private Sub cmdNewProject_Click()
'set focus to sbfProject
sbfProject.SetFocus
'navigate to new record
DoCmd.GoToRecord , "", acNewRec
End Sub
View 2 Replies
View Related