473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

When setting my recordset after opening the query it hangs.m Im using a subform.

3
This hangs on this line Set frm.Recordset = rsPro
when my query is already set.

Public Sub loadDataMainProFiltered()
Dim rsPro As DAO.Recordset
Dim strQuery As String

strQuery = "SELECT TabProduct.ProductDescription, TabTransaction.TransactionDescription" _
& " FROM ((TabProcess INNER JOIN TabEmployeeRegion ON TabProcess.RegionID = TabEmployeeRegion.ID) INNER JOIN" _
& " TabEmployeeTower ON TabProcess.TowerID = TabEmployeeTower.ID) INNER JOIN (TabProduct INNER JOIN TabTransaction" _
& " ON TabProduct.ID = TabTransaction.ProductID) ON TabProcess.ID = TabProduct.ProcessID" _
& " WHERE (((TabEmployeeRegion.EmpRegion)='" & cmbRegion.Value & "')" _
& " AND ((TabEmployeeTower.Tower)='" & cmbTower.Value & "')" _
& " AND ((TabProcess.ProcessDescription)='" & cmbProcess.Value & "'));"

Set daoDb = DBEngine.OpenDatabase(strPathForSub, False, False)
Set frm = Form_subViewProcess
Set rsPro = daoDb.OpenRecordset(strQuery)
Set frm.Recordset = rsPro

With frm
.ProductDescription.ControlSource = "ProductDescription"
.TransactionDescription.ControlSource = "TransactionDescription"
.ProductDescription.ColumnWidth = -2
.TransactionDescription.ColumnWidth = -2
End With

Set rsPro = Nothing
Set daoDb = Nothing
End Sub
Dec 13 '16 #1
3 900
jforbes
1,107 Expert 1GB
I've never used this approach, but it looks like it could work. Mostly what concerns me is setting the Form.Recordset to rsPro and then later setting rsPro to Nothing. I believe rsPro would be a pointer, so when setting rsPro to Nothing it sets the Form.Recordset to Nothing.

You might want to try an approach where Access creates and manages the Recordset for you:
Expand|Select|Wrap|Line Numbers
  1. Public Sub loadDataMainProFiltered()
  2.  Dim rsPro As DAO.Recordset
  3.  Dim strQuery As String
  4.  
  5.  strQuery = "SELECT TabProduct.ProductDescription, TabTransaction.TransactionDescription" _
  6.  & " FROM ((TabProcess INNER JOIN TabEmployeeRegion ON TabProcess.RegionID = TabEmployeeRegion.ID) INNER JOIN" _
  7.  & " TabEmployeeTower ON TabProcess.TowerID = TabEmployeeTower.ID) INNER JOIN (TabProduct INNER JOIN TabTransaction" _
  8.  & " ON TabProduct.ID = TabTransaction.ProductID) ON TabProcess.ID = TabProduct.ProcessID" _
  9.  & " WHERE (((TabEmployeeRegion.EmpRegion)='" & cmbRegion.Value & "')" _
  10.  & " AND ((TabEmployeeTower.Tower)='" & cmbTower.Value & "')" _
  11.  & " AND ((TabProcess.ProcessDescription)='" & cmbProcess.Value & "'));"
  12.  
  13.  Me.RecordSource = strQuery 
  14.  
  15.  ' Might not need this if the Control Properties are set through the Designer
  16.  '---------------------------------------------------
  17.  With frm
  18.  .ProductDescription.ControlSource = "ProductDescription"
  19.  .TransactionDescription.ControlSource = "TransactionDescription"
  20.  .ProductDescription.ColumnWidth = -2
  21.  .TransactionDescription.ColumnWidth = -2
  22.  End With
  23.  '---------------------------------------------------
  24.  
  25.  End Sub 
Dec 13 '16 #2
jeckoi
3
Thanks for the response Jforbes. But I forgot to mention my database is from a separate file which is the backend database of my access user form. That's why the suggestion you have given doesn't work if my database is separate from my front end database.
Dec 14 '16 #3
jforbes
1,107 Expert 1GB
I'm curious why you don't Link to the tables in the other Database. If you Link to them, then you can use them as they were tables in the current Database and all the hoops you are jumping through go away.

Maybe this could be of use to you: Working with Front and Back-Ends
Dec 14 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joseph VanWagoner | last post by:
I have a field called 'Details' that is of type 'Memo' I have a query that says: "SELECT * FROM TableName WHERE Details LIKE '*Ceiling Tile*';" I know that there are memos in the Details field...
1
by: Dai Hao | last post by:
Hi all, I have sql query to search for fields in a rather big view. If I execute the query in sql server enterprise manager, the results will be displayed in less than 6 seconds. However, if I...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
1
by: hansolox1 | last post by:
The following program simply sets the icon of a form called form1. When I get the name of the embedded icon using GetManifestResourceNames(), I store the name in a string variable called s. The...
1
by: Maarten van der Cammen | last post by:
Hi, In a table I have two numeric fields (e.g. FieldA and FieldB). Both fields have double precicion (field size "double"), Format "Fixed" and Decimal places "3" since I want to calculate with...
4
by: dougmeece | last post by:
Good Morning again everyone, I am having trouble understanding how to display the results from my query in a subform instead of it opening a separate window. I have a form that queries a...
0
acoder
by: acoder | last post by:
Problem When setting the FORM object's action property an "Object does not support this property or method" error occurs Browser Internet Explorer 6- Example The Javascript code: var...
1
by: Simon van Beek | last post by:
Dear reader, After same changes it is required to requery (refresh) query in a sub form. The code below is not working:
3
by: walshm | last post by:
Good morning! I am using Access 2007. I have two forms that are for other users to enter data. Form 1 is strictly a "search" type form. There are two command buttons to allow the user to...
3
by: shrysh | last post by:
i've placed a query as a subform and an action button to run the said query. whenever i click the ' run query' button, it opens another tab and shows the query. i want the query to get updated in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.