Changing "record Source" In SubReports With VBA

Mar 28, 2005

I have an application with a form where 20 subforms are used to add data to the same table. The 20 subforms are used to divide the data being added into categories ( think of a grocery store with categories of "Meat", "cereal', vegitables etc)
I use the same subform (with different names) and change the record source on the formOpen event to change the subforms properties. A portion of the code is shown below.

tempRecordSource = "SELECT [tSkills Assessment].Skill, [tSkills Assessment].Scale, [tSkills Assessment].Comments, [tSkills Assessment].AreaOfFocus, [tSkills Assessment].SubSectionTitle " & _
"From [tSkills Assessment] WHERE (([tSkills Assessment].SubSectionTitle)=" & Chr(34) & tempSubSectionTitle & Chr(34) & " and ([tSkills Assessment].SkillsAssessmentID)=" & [SkillsAssessmentID] & ") ORDER BY [skillOrder];"
Me(tempSubFormName).Form.RecordSource = tempRecordSource

I use an array to feed the code (which is in a loop) the variables needed to assign the correct properties to all the subforms.

And it works great. Yes I know I could have created 20 different subforms, but in an attempt to keep my application simple I am trying to have less objects.

The problem is in my output (the Report).

When I try to do the same thing on subreports it doesn't work. I figured the logic should be the same but the code that corresponds to the form code "Me(tempSubFormName).Form.RecordSource = ..." doesn't work. Either the logic is wrong or I am not using the correct event???

I have tried every combination I could find on the internet and $300 worth of Access manuals but no luck. Any ideas?????

View Replies


ADVERTISEMENT

How To Use Same Form By Changing Record Source?

Feb 8, 2005

Hi all,

I have Form F_CashSalesHead with a subform F_CashSalesInvFoot with one-2-many relationship on their tables. Subform contains a checkbox field that I use to lock the record set (On a command button click it runs one update query to add value 1 to each checkbox to make Enable=False all the records of current invoice on the form).

One-2-many relation ship is made on InvNum field in both tables.

When I open F_CashSalesHead form, bcz of some code line I wrote on On Load event of F_CashSalesHead , at the beginning it give massage how many invoices are pending to lock and would you like to see. If click Yes to see list, it opens a small form that called F_Count_Unlocked_Invoices showing invoice numbers and unmarked checkbox which is pending to lock. This small form is based on following query,

SELECT DISTINCTROW T_CashSalesInvFoot.InvNum, T_CashSalesInvFoot.CashSalesCustomerName, Sum(T_CashSalesInvFoot.Lock_Cash_Inv) AS [Sum Of Lock_Cash_Inv]
FROM T_CashSalesInvFoot
GROUP BY T_CashSalesInvFoot.InvNum, T_CashSalesInvFoot.CashSalesCustomerName
HAVING (((Sum(T_CashSalesInvFoot.Lock_Cash_Inv))=0));

This works fine.

What I am looking for is, I want to use the same F_Count_Unlocked_Invoices form for Credit Sales invoice also with the same trick. Because I dont want to create another same form and write code that help to increase size of db.

Can it be done just by changing record source of form F_Count_Unlocked_Invoices? Or what is the way to do it?

With kind regards,
Ashfaque

View 2 Replies View Related

Changing Record Source On Subform

Mar 25, 2005

Hello, I have a form with a subform. I want to change the record source on the subform during an OnClick event. I am not sure what I'm doing wrong, but I get a "object does not support this method" error. Can anyone help? Thanks in advance.

View 1 Replies View Related

Forms :: Changing The Record Source From Within A Subform

Nov 2, 2014

Can I change the Records Source of a subform from within that subform and do a requery to have a different set of records displayed'

I want to be able to refine the records displayed in the subform

View 8 Replies View Related

Forms :: Changing Record Source Of Query Profile

Nov 4, 2013

My form has a Record Source of qry_Profile, it is a query that shows the user the records of the dogs that they currently own. I want to put a button in the form footer to allow the user to show the records of all the dogs that they have ever owned.

So my question is how do I change the record source with vb.

View 1 Replies View Related

Changing Record Source - No Functions / Events Work

Oct 24, 2012

I have created a system consisting of a data entry form etc. It was originally connected to one record source exported from a sharepoint site.I had to add a field to the sharepoint site and so i created this additional field and re-exported the data and changed the forms record source and all occurences in the code of previous to new record source.

However, this change of record source produces the following error on every single event.The expression On Load you entered as the event property setting produced the following error: member already exists in an object from which this object module derives.

I tried to break the code as soon as it hits the load function to track the error - but it doesn't even run this function so the code is not executing at all.When i connect back to the old record source it works fine.

View 1 Replies View Related

Modules & VBA :: Changing Record Source On A Form - 2 Different Outcomes Using Same Bit Of Code?

Apr 28, 2015

I'm changing a record source on a form when the user clicks a "save" button.

I'm doing this to store a value from the current form in a table that is not part of the default form query.

This works fine.

I have a separate button on my form called "Home", when the user clicks this button it requerys the current form which triggers the before update event to run, this in turn brings up a message box which asks the user if they want to save or not. If they click yes then it runs the SaveButton click() code.

For some reason when the user presses the save button and then exits, everything works but if a user presses the “home” button which triggers the save button then it brings up the “2107 The Value you entered doesn’t meet the validation rule defined for the field or control.” Runtime error and stops on the change recordsource command.

Why triggering the same code directly from a button or indirectly from a before update event has two different outcomes.

View 4 Replies View Related

Report With Subreports - If Subreports Grow, Other Fields Move

Oct 19, 2004

I have a report with several subreports that occassionally grow. I also have several fields that don't grow. If my subreport grows, it moves any other fields down as well. These are fields that are below the subreport, but not beneath it (e.g. on a lower line, but to the left).

Is there any way to keep the other fields stationary?

Thanks!

View 2 Replies View Related

Changing The Source Of A Textbox

Jul 14, 2006

A simple question that would probably take me hours to figure out by myself: When I want to change the source of a listbox, fx. when a button is clicked, i use the command 'rowsource ='. But what command do i use to change the source of a textbox...??

Thank you in advance :-)

// JR

View 5 Replies View Related

MDB....underlying Changing Data Source

Dec 1, 2006

Hi!

I have an MDB file that points to a postgres database. What I'm trying to do is to redirect it to another datasource. The database is exactly the same, but I just need to point it to a different location. I tried doing this with linked table manager by refreshing the table and enabling the "always prompt for new location". I was able to point to my new location but what happened was my MDB became readonly, I am unable to edit anything after I changed the datasource.

View 2 Replies View Related

Forms :: Changing Source Of Combobox

Jan 26, 2014

I have a form (named Example) to create reports by selecting fields from tables or queries. there is a option box (name is KynkSec) with two options (Table, Query) and a combobox named as KynkTurSec.I want to change the data source of combobox either table or query. By afterupdate, that combobox is requering the listbox "ListKynkAlan" and I can see fields of selected table or query. (That is my dream))Unfortunately I can not do that. Combobox is showing only tables or both of tables and queries. But not only query.

Here is str source of my combobox:

SELECT MsysObjects.Name, MsysObjects.Type FROM MsysObjects WHERE (((MsysObjects.Type)=1) AND ((Left$([Name],1))<>"~") AND ((Left$([Name],4))<>"Msys")) OR (((MsysObjects.Type)=5) AND ((Left$([Name],1))<>"~") AND ((Left$([Name],4))<>"Msys")) ORDER BY MsysObjects.Name; That is showing both of tables and queries.

And I wrote a code for KynkSec option box;

Private Sub KynkSec_AfterUpdate()
' Populate rowsource of KynkTurSec
Dim strSQL As String
On Error GoTo HandleErr
Select Case KynkTurSec

Case 1

strSQL = "SELECT MsysObjects.Name FROM MsysObjects" _
& WHERE(((Left$([Name], 1)) <> "~") And ((MsysObjects.Type) = 1) And ((Left$([Name], 4)) <> "Msys"))
Order BY(MsysObjects.Name)

Case 2

strSQL = "SELECT MsysObjects.Name FROM MsysObjects" _
& WHERE(((Left$([Name], 1)) <> "~") And ((MsysObjects.Type) = 5) And ((Left$([Name], 4)) <> "Msys"))
Order BY(MsysObjects.Name)
Case Else
End Select

[code]...

But this code is not working and giving a warning messsage "Sub or function is not defined"..So How can I change the source of combobox, either table or Query?

View 3 Replies View Related

Changing ODBC Data Source?

Jul 23, 2014

I am having difficulty with my Access database, when I run a particular query. The query is linked to a table in SQL Server, but I keep getting a "ODBC -Call Failed" error message. After some research I understand I might need to change the ODBC Data Source, but this is something I have never done and am unsure of how to do it so my query will work!

View 2 Replies View Related

Remove Record Source/Control Source

Sep 19, 2005

I have an unbound form with three tabs. On each tab there is a sub form. Each tab is a search form and each sub is a results returned. I have made everything unbound and set the sub form recordsource and its controls control souce on afterupdate of the main form search criteria. Works fine except for after some use the db decides the sub forms are not unbound and sets the record source and control sources.

I'm trying to do a

Me.PollingPlacesResults.Form.RecordSource = ""
Me!PollingPlacesResults!PollID.ControlSource = ""


but this does not seem to work in actualy removeing the record source and control source.

View 14 Replies View Related

Changing Data Source (table) For A Query

Jul 18, 2006

Hi,

I have two Tables TA and TB. I have a set of queries based on TA. I want to substitute TB for TA (i.e. TB will stand in place of TA). I want the old TA queries remain unchanged but now be based on TB.

If I delete TA and then rename TB into TA, I will lose the queries. Therefore I want to 'point' the queries (in the most efficient way) to TB instead of to TA.

Then I can delete TA. Then I can rename TB into TA and the queries will follow along, I expect.

I have been trying in vain to find a way of pointing the queries to TA instead of TB? How do I do it?

I have done it with Forms (Design Views, Properties), where I can select a datasource. But where is the corresponding thing enabling me to select a datasource for Queries?

Thanks.

Adrian

View 13 Replies View Related

Changing Source Database String On Append.

Feb 12, 2007

Hello,

I think i've done this before but I can't seem to remember the process so any help would be great. What im trying to accomplish here is I have a database that will be updated(new data appened) to on a daily basis from many other databases, but the data that is to be appened can come from various destination drives ie (C: drive, D:drive, CD, Thumbdrive, etc). I set up a dialog box that prompts the user to select the source database, but im not sure how I can store that source destination string and update my append query with that source database string. I believe there is a way to do this. Am I making any sense? Any help would be so great. Thank you in advance.

-James

View 1 Replies View Related

Changing Table Source In Query Using Vb Instead Of Manually Doing It.

Aug 17, 2004

I have a Query called Median and all it does is pulls all the fields and all the records from 1 table. Since the Query is connected to a lot of other queries, and the table it's connected to changes twice a month, I was wondering if there was a way to set this up in a form maybe using vb, so a user could maybe Click a new table from a combo box list of current tables in the database, then click a button that says "Change", and it change all the fields to the new table and removes the old table from the query.

Or what might be better is: Already on the form, i have part of the name of the new table already entered by the user (it bases the new name of the new table off this text box). So, what I can use is the Text in that box and an & " the rest of the tablename", and automatically change the table in the Median Query based on that criteria. If that is too complicated, then a combo box will be sufficient.

Another way i guess, would be to setup a hidden field that takes whatever's in my text box (which is a date) and adds " the rest of the tablename", then I could base the replacement table of the Median on that one text box.

Anyway, is there a way to do this?

View 6 Replies View Related

Changing Subform Source Object Causing Problems

Aug 30, 2005

I'm trying to change a database that consists of a sequence of subforms held individually within different tabs on a subform. There seems to be a bit too much going on, so I've decided to leave the subforms unbound, and set them when the appropriate tab is selected, and unset them when the tab is changed. For most of the subforms, this works fine...

However! There's always an exception!!!

On one of them, when I set the sourceobject, it automatically populates the linkchildfields and linkmasterfields properties with an inexplicably crazy number of fields, most of which aren't even on the forms in question. I've tried to get around this by setting linkchildfields and linkmasterfields after changing the sourceobject. This does not work!

The first thing that happens is it returns error 2335 (relating to an imbalance between the number of fields) when I set linkchildfields. I try to get around this by trapping and resuming to the next step so it sets linkmasterfields and restores the balance, but, despite the fact that the linkchildfields and linkmasterfields are showing the correct fields, the form acts as if it has been bound with the screwy list of fields, and starts asking for fieldnames which are on neither form as parameters. When I hit cancel the subform control is empty.

I'm at a loss as to what the problem is or how I should sort it out! Any suggestions gratefully received.

View 2 Replies View Related

Changing Data In Query Results Changes Data In Source Table

Dec 17, 2012

I have a table and a simple query that pulls results from the table. Nothing too crazy. But, if I were to go in and change some of the data/values in the query results it will change the respective data in the table. I know that this cannot be right. What do I have to do to either prevent the ability to change query results and/or prevent any changes in the query from altering the original data in the table.

View 2 Replies View Related

Modules & VBA :: Record Of Changing Another Record In Database

Apr 21, 2015

I need any code or way that whenever any field of a record according to unique ID changed the code must save the changed field name and the current date in a specific field in another table (first field store the ID and the second one detail about changes) with add record mechanism. Suppose I have a table about the information of students with the name std_info and another info_report and when any changes make to the any field of std_info the field number and the unique ID to the table info_report. I want to use this system to record which user make changes to which records.

View 1 Replies View Related

Set Record Source Of Combo Box

Apr 25, 2005

Hi all,

I have a form with a combo box on it and what I would like to do is when I click a command button, change the record source of the combo box from the query I currently have to a different one?

Is this possible,

Thanks for your time.

Taff.

View 8 Replies View Related

Record Source From Another SQL Database.

Nov 2, 2006

I have multiple SQL databases and on most have searches built on stored procedures.

I'd like to create a central search database but can't get Forms to go across SQL databases to get their record source.

Am I being thick?

View 2 Replies View Related

Record Source Does Not Exist

Oct 7, 2004

I have set up a simplified event booking procedure, similar to the one generated by the access event manager wizard. It uses three tables, one with attendees details, one with the event details and abooking table that links the attendee ID with the Event ID.

The booking table uses commands similar to SELECT[Names + Contacts].[ID],[Names + Contacts].[Surname]FROM[Names + Contacts] to generate drop down lists of surnames and events so that the two can be matched together.

This works fine as a table.

However when placed into a form, whenever the form is opened I get an error message saying the record source specified on the form does not exist.

I have tried regenerating the form, etc. I have used a wizard to generate the form, closed the form, not changed anything in the database and then tried reopening it and I get the error message, can anyone shed any light?

Also if you accept the message then it knows how many records there are, so it must know there's something behind it, also if you change to design mode and then back to form mode, it finds all the data.

View 4 Replies View Related

Help With Record Source And Recordset

Jan 24, 2005

I have a form with a record source already defined (used so the user can browse through records and edit them)
I have the form store requirement ids and not the name however I would like to present the requirement name rather then the id to the user
So it tried with a sql query and a recordset but I keep getting the error data type mismatch in criteria expression on this line
Set rsm = dbm.OpenRecordset(sRequirementName1)

I think the problem is having the record source already defined and then having a new Recordset not sure how to work around it

here is the code
----------------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub Next_Click()

Dim sRequirementName1 As String
Dim queryResult As String
Dim wsm As workspace
Dim dbm As Database
Dim rsm As Recordset

sRequirementName1 = "SELECT Requirements.RequirementName " & _
"FROM Requirements " & _
"WHERE Requirements.RequirementID = '" & Me.RequirementID11.value & "' "


Set wsm = DBEngine.Workspaces(0)
Set dbm = wsm.OpenDatabase("E:Practicum Hours.mdb")
Set rsm = dbm.OpenRecordset(sRequirementName1)

queryResult = rsm.Fields(0)

Me.HoursCompleted11_Label.Caption = queryResult


End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------------

I have also attached the DB if anyone thinks they can help, if you are confused about what i am trying to do with the modify form i made one with students that works
it is the modify hours1 form and the code above is the on click event for the next button

Thanks for any help anyone might offer

View 2 Replies View Related

Change The Sub Forms Record Source

Nov 16, 2005

I have a main form that has 10 sub forms Each sub forms record source is link to a different Query.

It takes more then a minute to open the form, (because its running the query for all sub forms). So I changed the sub forms source to SELECT * FROM tblTest WHERE false;

I also changed the main form. When the button on the main form is clicked, its adding the following:

Me.SubMySub.Form.RecordSource = "select * from qMyQuery"
Me. SubMySub.Form.Requery

However, after I close the main form, the sub forms record source stays linked to
SELECT * FROM qMyQuery;

And will take the same long time again to open the main form.

Does anyone have any solution?

View 7 Replies View Related

Cacading Combobox Record Source

Mar 18, 2005

Hi, I need help on cascading combo boxes, in my form


In my example DB i have 3 tables(when i find a soloution i will implement it on a larger scale database which will have around 15 tables). I need to create reports of these tables. The problem was that i need to filter the data before i create the report by 2 fields. If i was to do this the straight forward way i would have 3 tbls, 3 qrys and 3 reports (which on my final database would mean 15 of everything.)

So i've decided to use a form driven system to reduce the number of forms and querys i have in the DB. Using a form based system i should have 3 Tables (called 1, 2 and 3), 1 Query (called query2), 1 Form (called withselect) and 1 report (called rptquery1).

Now to the system.

The form should have 3 combo boxes. 1 at the top to select the table i want to query. Then 2 others to select the fields by which to filter. the form should also have 2 buttons, 1 torun the report one to return reults in a table to edit the data if needed.

This is the current problem i am having

In the forms 1st combo box i have managed to list all my 3 tables (thanks to FancyPrairie) using the following code:

SELECT MSysObjects.Name, MSysObjects.Type
FROM MSysObjects
WHERE (Left$([Name],4)<>"MSys") AND (Left$([Name],4)<>"USys") and (Left$([Name],1)<>"~") and (MSysObjects.Type=1)
ORDER BY MSysObjects.Name;

But i cant select any thing in the following 2 comboboxes. At the moment im tryin to use this code in the record source of the 2nd and 3rd combo boxes

SELECT * FROM YourTable WHERE (YourTable.TableName=[Forms]![withselect]![Combo6]);


Attached is the latest version of the DB.

Im getting the error:

The record source 'SELECT * FROM YourTable WHERE (YourTable.TableName=[Forms]![withselect]![Combo6]);' specified on this form or report does not exist.

Hopefully someone can help.

View 6 Replies View Related

Cascading Form Record Source

May 17, 2005

Heya. I hate posting yet another cascading query but I just poured through the first 40 bits and couldn't find something similar.

Basically, I seem to have an errored idea in how to effectively used cascading boxes on a larger form-wide scale.

Basically I have a form with an unbound combobox in the form header: cboSchool

The detail section should only have two fields, StudentID (txtStudentID) and a boolean (bolOT) both of which exist in a specific table source (tblStudents). StudentID is a locked field.

What I would like to do is only have the StudentID's available that are valid for the school. I attempted using a query in the record source that would reference cboSchool but I keep ending up with blank forms. (There's a string of queries that link the schools found in cboSchools to StudentID)

Any ideas?
~Chad

View 5 Replies View Related







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