Advertisement

05.07.2008 at 08:55AM PDT, ID: 23383258
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

How to create and use an Access Form that runs off of a VBA created recordset, not an instantiated query!

Tags: Microsoft, Access, 2003, Access Forms
I am trying to create a form in Access 2003 that when loaded is unbound, but after a user selects some values from a set of drop-down boxes will subsequently be bound to a recordset created in VBA in response to the values selected by the user.

I do not want to have to select from a saved query, as the Access database will be used in a multiuser environment and if anything is saved then there are continuity and integrity problems. I want to keep as much information being passed around in memory as possible.

The data for the recordset comes from a pass-through query which I temporairily instantiate with a random-numbered query name, store the results in a recordset, and then delete the query. If I pass the recordset to a listbox the values can be seen quite clearly. If I pass the recordset to the Form, the text boxes on the form continue to show #Name and won't populate correctly (apart from sometimes when I'm debugging it randomly works! but when I colse the form and reopen it it breaks again :S )

This is the code I am using to assign the recordset to the form:

Set Form_Dedupe_Analysis.Form.Recordset = get_cfp_record(record_list.value)

Where get_cfp_recordset returns a DAO recordset and record_list is a listbox. If I use this command:

Set adam_test.Recordset = get_cfp_record(record_list.Value)

I get what I want but in the wrong format (I don't want a list box I want a form with text boxes!), what can I do to get what I want?

Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: adamsmithve
Solution Provided By: LPurvis
Participating Experts: 2
Solution Grade: A
Views: 0
Translate:
Loading Advertisement...
05.07.2008 at 10:09AM PDT, ID: 21518383

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 11:06AM PDT, ID: 21518885

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 11:25AM PDT, ID: 21519035

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 11:31AM PDT, ID: 21519110

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 01:08AM PDT, ID: 21523059

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 03:36AM PDT, ID: 21531530

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.14.2008 at 04:04PM PDT, ID: 21569403

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.16.2008 at 04:13AM PDT, ID: 21581726

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.16.2008 at 06:30AM PDT, ID: 21582474

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.04.2008 at 07:15AM PDT, ID: 21710315

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.04.2008 at 07:20AM PDT, ID: 21710359

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.04.2008 at 07:24AM PDT, ID: 21710414

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.25.2008 at 07:28PM PDT, ID: 21871382

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.29.2008 at 07:05AM PDT, ID: 21894106

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.07.2008 at 10:09AM PDT, ID: 21518383

Rank: Genius

Can you include a bit more of your code (well - more like all of it really).
Cheers.
 
05.07.2008 at 11:06AM PDT, ID: 21518885

Rank: Genius

Any chance you can just create separate forms, bound to their respective recordsets?

This sounds like a runtime error(s) waiting to happen.
 
05.07.2008 at 11:25AM PDT, ID: 21519035

Rank: Genius

Can you elaborate a bit on what you mean Jim?
Bound forms to persisted querydef objects?

A concern of mine from the question is that this sounds like a shared front end (due to the random object naming and immediate deletion).
A distributed FE (standard split architecture) would negate such needs and allow a more standard binding.
And there shouldn't be any need for a persisted query def at all - if that's what's required.  The querydef object alone should be enough - without a saved query.
But I would still like to see more of the code to understand the big picture as well as diagnose the problem here.
 
05.07.2008 at 11:31AM PDT, ID: 21519110

Rank: Genius

I interpreted this question as one form, different recordsets that will have different schemas, which means VBA code will be adding/deleting/hiding/unhiding controls on the Load event.
 
05.08.2008 at 01:08AM PDT, ID: 21523059
Hi Guys,

Thanks for your responses,

I am using this code to fetch my data from a remote database:
****************************************************************************************
Public Function get_cfp_record(Match_Key As Long) As DAO.Recordset

    Dim myQuery     As DAO.QueryDef
    Dim myRecSet    As DAO.Recordset
   
    Set myQuery = CurrentDb.CreateQueryDef(get_random_num(Now()))
    myQuery.Connect = ODBC_CON
    myQuery.SQL = "EXECUTE PROCEDURE get_cfp_record(" & Match_Key & ");"
   
    Set myRecSet = CurrentDb.OpenRecordset("SELECT Expr1000 as Extract_Key, Expr1001 as Match_Key, Expr1002 as Match_Type, Expr1003 as Creation_Dtime, Expr1004 as Index_Number, Expr1005 as Index_Desc, Expr1006 as H1_Creation_Date, Expr1007 as H1_External_Id, Expr1008 as H1_Gi_Tmp_Key, Expr1009 as H1_Cky," & _
                             "Expr1010 as H1_Crk, Expr1011 as H1_Store_No, Expr1012 as H1_Title, Expr1013 as H1_Forenames, Expr1014 as H1_Surname, Expr1015 as H1_Dob, Expr1016 as H1_Dob_Str, Expr1017 as H1_Gender, Expr1018 as H1_Organisation, Expr1019 as H1_Thoroughfare," & _
                             "Expr1020 as H1_Dbldep_Locality, Expr1021 as H1_Dep_Locality, Expr1022 as H1_Town, Expr1023 as H1_Postcode, Expr1024 as H1_Post_Out, Expr1025 as H1_Post_In, Expr1026 as H1_Dps, Expr1027 as H1_Addrk, Expr1028 as H1_Home_Tel, Expr1029 as H1_Work_Tel," & _
                             "Expr1030 as H1_Mobl_Tel, Expr1031 as H1_Fax_Tel, Expr1032 as H1_Email, Expr1033 as H1_Rx_Category, Expr1034 as H1_Spare, Expr1035 as H1_Goneaway, Expr1036 as H1_Deceased, Expr1037 as H1_Sn_Rank, Expr1038 as H1_Cf_Cust, Expr1039 as H2_Creation_Date," & _
                             "Expr1040 as H2_External_Id, Expr1041 as H2_Gi_Tmp_Key, Expr1042 as H2_Cky, Expr1043 as H2_Crk, Expr1044 as H2_Store_No, Expr1045 as H2_Title, Expr1046 as H2_Forenames, Expr1047 as H2_Surname, Expr1048 as H2_Dob, Expr1049 as H2_Dob_Str," & _
                             "Expr1050 as H2_Gender, Expr1051 as H2_Organisation, Expr1052 as H2_Thoroughfare, Expr1053 as H2_Dbldep_Locality, Expr1054 as H2_Dep_Locality, Expr1055 as H2_Town, Expr1056 as H2_Postcode, Expr1057 as H2_Post_Out, Expr1058 as H2_Post_In, Expr1059 as H2_Dps," & _
                             "Expr1060 as H2_Addrk, Expr1061 as H2_Home_Tel, Expr1062 as H2_Work_Tel, Expr1063 as H2_Mobl_Tel, Expr1064 as H2_Fax_Tel, Expr1065 as H2_Email, Expr1066 as H2_Rx_Category, Expr1067 as H2_Spare, Expr1068 as H2_Goneaway, Expr1069 as H2_Deceased," & _
                             "Expr1070 as H2_Sn_Rank, Expr1071 as H2_Cf_Cust, Expr1072 as Title_Match, Expr1073 as Title_Score, Expr1074 as Gender_Match, Expr1075 as Gender_Score, Expr1076 as Fn_Match, Expr1077 as Sn_Match, Expr1078 as Name_Match, Expr1079 as Name_Score," & _
                             "Expr1080 as Dob_Match, Expr1081 as Dob_Score, Expr1082 as Dob_Fuzzy, Expr1083 as Dob_Year, Expr1084 as Dob_Y1, Expr1085 as Dob_Y2, Expr1086 as Dob_Y3, Expr1087 as Dob_Y4, Expr1088 as Dob_Month, Expr1089 as Dob_M1," & _
                             "Expr1090 as Dob_M2, Expr1091 as Dob_Day, Expr1092 as Dob_D1, Expr1093 as Dob_D2, Expr1094 as Pc_Match, Expr1095 as Addrk_Match, Expr1096 as Non_Paf_Elements, Expr1097 as Address_Match, Expr1098 as Address_Score, Expr1099 as Telephone_Match," & _
                             "Expr1100 as Telephone_Score, Expr1101 as Email_Match, Expr1102 as Email_Score, Expr1103 as Rx_Cat_Match, Expr1104 as Rx_Cat_Score, Expr1105 as Organ_Match, Expr1106 as Organ_Score, Expr1107 as Spare_Match, Expr1108 as Spare_Score, Expr1109 as Auto_Match," & _
                             "Expr1110 as Auto_Match_Desc, Expr1111 as User_Review, Expr1112 as User_Review_Desc, Expr1113 as Manual_Match, Expr1114 as Manual_Match_Dtime, Expr1115 as Processed_Flag, Expr1116 as Processed_Dtime, Expr1117 as Match_Score" & _
                             " FROM " & myQuery.Name & ";")
   
    If myRecSet.RecordCount <> 0 Then
        myRecSet.MoveLast
        myRecSet.MoveFirst
    End If
   
    Set get_cfp_record = myRecSet
   
    'DoCmd.DeleteObject acQuery, myQuery.Name

End Function

************************************************************************************


This code is called from here:

Private Sub record_list_Click()
    Set Form_Dedupe_Analysis.Form.Recordset = get_cfp_record(record_list.Value)
End Sub

'record_list' is a list box on the form, when I select a record from that list I want to display the details of it on the form, so the idea was to assign the recordset containing that record to the form's recordset. The underlying schema of the recordset will always be the same.

I have commented out the deletion of the query because that seems to cause more problems than it solves and I haven't added error code for the same reason. I will obviously add these once the core functionality is working.
 
05.09.2008 at 03:36AM PDT, ID: 21531530
Anybody have any ideas? I can post more information if required.
 
05.14.2008 at 04:04PM PDT, ID: 21569403

Rank: Genius

OK sorry for the delay in getting to look at this.
Are you saying that the procedure *without* deleting the query doesn't cause the form binding to fail?

Firstly - that's a fearsome SQL statement.  I'd definitely assign that to a string variable first before opening the recordset.  What is the source - for so many ExprXXX fields to be present and need aliasing?  Could they not be aliased on the server?

And that is the *entire* code you're using?
I still don't see the reason for it losing the form's recordset.
However, that said - I only have a SQL Server instance as an ODBC source... and you're not using that are you? (i.e. "EXECUTE PROCEDURE")

Your need to alias all of the fields is one hinderance (it prevents you from just directly creating an in-memory querydefinition instead of the saved and then deleted one).

As a workaround - you might have better luck with a client side ADO recordset...
At least then you could disconnect it - to ensure that there is no source to be dependant upon...
 
05.16.2008 at 04:13AM PDT, ID: 21581726
The reason for all the aliasing is that I'm calling a stored procedure from an Informix database which returns a single record. An unfortunate side effect of calling an Informix Stored Procedure is that you lose all the field names, so I have to manually rename the fields using the above sql. This works fine normally for DAO recordsets that I attach to a listbox.

What I want to do now is take a recordset (which I can attach to a listbox and view the data without problem) and assign it to a form's recordset, but when I do this the form seems to ignore the recordset that I try to assign to it using the statement:

Set Form_Dedupe_Analysis.Form.Recordset = get_cfp_record(record_list.Value)

If I pause the code after this line and run these commands in the debug window I get:

?Form_Dedupe_Analysis.Form.Recordset.recordcount
 1
?Form_Dedupe_Analysis.Form.Recordset.fields(1).name
Match_Key

Which shows the forms recordset is populated, but the fields on the form whose controlsource is match_key doesn't update, it just continues to show #Name?

What can I do to make this work??!?!?!?!?!?

If there is a solution to this is ADO then I would give that a try but I have no experience with ADO at all.
 
05.16.2008 at 06:30AM PDT, ID: 21582474
Another alternative would be to run an sql on the database but I would need to be able to run this Informix specific command:

"SET ISOLATION TO DIRTY READ;"

before running the sql so that even if the table is locked Access could still read it (At the moment this is handled by the stored procedure)
 
06.04.2008 at 07:15AM PDT, ID: 21710315

Rank: Genius

Sorry for the big gap.
I did some testing - but I've not got it to hand right now.
However I definitely don't have an Informix server to test on!

I'm not clear on what the need for the deleted query is.
Does this still fail even if you don't delete the query after opening the recordset?
(I know you'll need to delete it before the next run - but just as a one off I'm interested in here).

I'd imagine you'd be better off with ADO for binding a recordset to a form based on server data.
You can do it with DAO - but you're at the mercy of the ODBC driver then.
I assume updatability isn't required?
There's no such thing as a disconnected DAO recordset - which means you don't have any separation from the source.
 
06.04.2008 at 07:20AM PDT, ID: 21710359
I've managed to solve this now by rebuilding the form from scratch, and it works fine.

I can create disconnected DAO recordsets by creating a querydef with no name, running the query and then create the recordset, which I can now pass back to my form and set it as the form's recordset.

As the query has no name I don't delete it as I believe Access will handle deleting it once all references to it have been removed.
 
06.04.2008 at 07:24AM PDT, ID: 21710414

Rank: Genius

Glad you're sorted.

The scenario you've described doesn't mean that the recordset is disconnected though.
There really is no concept of a disconnected recordset in DAO.
It's bound to the data still - just not using a *saved* query definition as its source.  There's always a querydef at the source in Jet - whether it's saved or not.

The solution you've implemented seems to be what I mentioned in my second post:
"And there shouldn't be any need for a persisted query def at all - if that's what's required.  The querydef object alone should be enough - without a saved query."
Accepted Solution
 
06.25.2008 at 07:28PM PDT, ID: 21871382

Rank: Genius

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: LPurvis {http:#21710414}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

mbizup
EE Cleanup Volunteer
 
06.29.2008 at 07:05AM PDT, ID: 21894106
Forced accept.

Computer101
EE Admin
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628