473,387 Members | 1,515 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.

In subform, Recordsource=Query (updateable) while =Recordset(read-only)

Hello, I have a MS Access continuous subform that was using a query as the recordsource.

I changed it to use a recordset instead because when the query was used, the changes to the subform values directly changed the tables under the query. I wanted the changes to be 'in-memory' so that I could check them before applying them to the tables.

When I changed the subform to use the recordset, it is now 'read-only' and I can't change anything on the subform (bummer). Here is my creation of the recordset:
Expand|Select|Wrap|Line Numbers
  1.     Set rsLandSpecies = CurrentDb.OpenRecordset _
  2.     ("SELECT LandingSpecies.cd_Document, LandingSpecies.cd_Species, " _
  3.     & "Species.Description, LandingSpecies.Quantity, " _
  4.     & "LandingSpecies.Num_Indiv, LandingSpecies.Price, LandingSpecies.Value " _
  5.     & "FROM LandingSpecies, Species " _
  6.     & "WHERE LandingSpecies.cd_Document = " & tx_cd_doc.Value & " " _
  7.     & "AND LandingSpecies.cd_Species = Species.cd_Species " _
  8.     & "ORDER BY Description", dbOpenDynaset)
  9.     Set Me!SpeciesPerDocument.Form.Recordset = rsLandSpecies
  10.  
Am i missing some parameter to allow editing on the recordset while it is in memory?

Thanks for any assistance with this.
Sep 22 '09 #1
7 5612
Bummer#2
OK - I found out why the recordset was not editable - it was my query. I changed it to be:
Expand|Select|Wrap|Line Numbers
  1.     Set rsLandSpecies = CurrentDb.OpenRecordset _
  2.     ("SELECT LandingSpecies.cd_Document, LandingSpecies.cd_Species, " _
  3.     & "Species.Description, LandingSpecies.Quantity, " _
  4.     & "LandingSpecies.Num_Indiv , LandingSpecies.Price, LandingSpecies.Value " _
  5.     & "FROM LandingSpecies " _
  6.     & "INNER JOIN Species ON LandingSpecies.cd_Species = Species.cd_Species " _
  7.     & "WHERE (((LandingSpecies.cd_Document) = " & tx_cd_doc.Value & ")) " _
  8.     & "ORDER BY Species.Description", dbOpenDynaset)
  9.     Set Me!SpeciesPerDocument.Form.Recordset = rsLandSpecies
and now the subform is editable. The problem is that I'm back to actually immediatley updating the values in the tables again though i want to do it 'in-memory' Would anyone know if i make a clone of the recordset and then assign that to the subform, would that be editable in memory only? Thanks for any advice. Cheers, Tony
Sep 22 '09 #2
missinglinq
3,532 Expert 2GB
You're making a load of unnecessary work for yourself! Validation, what you're referring to as checking changes 'while in memory' should be done in the subforn's Form_BeforeUpdate event. prior to saving the record. If mistakes are found, you can cancel the update and make needed corrections.

Return you Record Source back as it was originally and do the validation in the Form_BeforeUpdate event. This is pretty standard stuff. If you need help with the code, post back detailing exactly what you need to check.

Welcome to Bytes!

Linq ;0)>
Sep 22 '09 #3
Hello Linq,

Thank you for the suggestion. That is not a good option though.

In the subform, I present many records in a continuous form (simulating a datagrid). I want to do the validation when the subform is exited (after all the records are updated). If I use the Form_BeforeUpdate event, validation is done after every record is changed. How would I do the validation when the subform loses focus?

Maybe I should use transactions? What do you think?

Thanks for any hints.
Sep 23 '09 #4
missinglinq
3,532 Expert 2GB
You wouldn't! Doing validation against multiple records at the same time just isn't done. If the user needs to make a correction to a record it should be done while that record's data is fresh in the user's mind, not after another five or ten or fifty records have been entered. Doing it as you currently are attempting is, to put it kindly, very poor design.

Linq ;0)>
Sep 23 '09 #5
@missinglinq



Poor design, eh... OK - how would ensure that all the weights (entered by the user within the subform) of the individual species samples (Quantity) sum up to the Q-sample total in the 'Document' record? There could be anywhere from 5 to 30 species. Like I have said twice, the subform is a continuous form (like a datagrid). Do you understand the design now? Do you still consider this a 'poor' design?

Thank you for your help. Regards, Tony
Sep 23 '09 #6
OldBirdman
675 512MB
I read this thread as an attempt to mimic Excel using Access.
In Excel, one can make changes anywhere in the grid, and when satisfied with the various subtotals and totals, can then save all the changes. If a solution is not found, none of the changes need to be saved.
I certainly can understand the uses of this approach. I don't know how to do this, but either Excel can do some database-like operations, or Access can create an Excel spreadsheet to be used here, and then converted back to Access as a 'Save' operation.
Sep 23 '09 #7
NeoPa
32,556 Expert Mod 16PB
@tnjarrett
Tony,

I'm sorry to say that Linq's right. That design is almost certainly going to leave you with problem after problem. That's why it's not done. Not simply because the more experienced developers have some strange form of snobbery about it. Most of us appreciate why it will naturally and unavoidably cause problems.

I'm sure you're not keen to hear that, but it's nevertheless true.

Good luck with your project anyway.
Sep 23 '09 #8

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

Similar topics

11
by: Ian Ornstein | last post by:
in posting http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&newwindow=1&selm=bmEK9.43452%24lj.1060600%40read1.cgocable.net Lyle showed us that an ADODB.Recordset can be created and attached to a...
1
by: Bill Strass | last post by:
Problem: Access main form/subform as front end to SQL Server backend. Add/edit via subforms work fine. Not so with main form. Set up a master-detail form-subform using two views linked from SQL...
3
by: Simone | last post by:
Hi All, I have a Find Record button setup in most of my forms in order to find a specific customer's details. I have just noticed today though that this search will only find the customer if it...
1
by: Ig | last post by:
Hi, I have subform on form that both are Allow Edits and both are dynasets. Subform is based on only 1 table. When trying to change field on subform, there is a message on status bar that form...
2
by: Bruce | last post by:
Hi, I have 3 nested forms and wish to calculate a value on Subform 1 by adding 2 values on the same subform + to a value in a control on the footer of the underlying subform . I use this as the...
2
by: JM | last post by:
Hello, I've created a Querydef in a Form_Load() sub. The form is a subform that no longer has linked child fields. The form is bound to this querydef. When I open the form, the fields are...
7
by: Stephen Poley | last post by:
I have the following situation: - a table of employees, keyed on employee-id; - a table of training sessions, keyed on session-id; - a requirement to log who was present at which session, plus...
7
by: Br | last post by:
I'm sure this has been answered before but I can't dig up any posts that give a good answer.. and I'm sure I've come across it before but forget how I dealt with it. I have an ADP (A2000,...
1
by: rdemyan via AccessMonster.com | last post by:
I tend to code everything. So I'm trying to set the recordset of a subform in code and then set the .ControlSource property of each field. The data is displaying correctly, but the subform isn't...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.