Good Evening, "Long time listener, first time caller."
MS Access 2007 - VBA - DAO
I have a procedure that updates values from textboxes on a form to a table with a rs object update method. Within that same procedure I am looking to pass the values back out to the same form with a different recordset. Is there a danger or reason for concern given the rs.update happens within the same sub I'm pulling the table values from? Or is there a "reasonable" time-frame I should give the write event to the table?
Thanks,
P
Example: -
button_click()
-
rs.AddNew
-
rs!myvalue = text1
-
rs.update
-
-
.....more code......
-
-
db.openrecordset
-
rs.fields("myvalue") = text1
-
-
End Sub
-
Once you do the rs.update you're good to go, there's no delay to worry about. However, if you're writing new records you should follow the rs.update with - rs.bookmark=rs.lastmodified
Jim
7 1111
No problem, but I'm not at all sure about the code you posted.
First, be sure to add - if me.dirty then me.dirty=false
before executing the code behind the form (between lines 1 and 2 above). That writes any changes on the screen to the recordset.
You haven't shown enough code for us to know for sure what is going on. Presumably rs and db have been defined and set elsewhere. But if the field is already on the screen it's not clear why you would need to pass the value back to the screen. That's where you got it to begin with.
Forget screens and recordsets for moment. Tell me if the piece of data that is being updated is in two different tables or not. If two different tables are needing to be udpated, the form on the screen can do one and your vba code can reach out to the other table and do that one. But if you're just trying to refresh the screen to get the data you just added to some table, and the form itself can not do that update, then you need only do a
to pull a new copy of the recordset onto the form.
Jim
Hi Jim,
Thanks for taking the time to help. I appreciate your time.
Let me preface with stating all of my objects are unbound. I wasn't completely clear with my explanation. My code is working fine so it's more of a question about the "predictability" of Access or Ace when and how it's writing to a table. Basically, can I pull out a value from the table I just wrote to in the same sub procedure?
1. Button Click
2. Use record-set behind an unbound button to save a "New" record to a table.
3. I then pull out the primary key value (which is autonumber), back to the form front end to a text box. (My conern is here. Will the autonumber have enough time to generate from step 2 before the code moves to this 3rd step?)
4. End Sub
I'm pulling out the primary key immediately to my form so I can then pass it to another form. Hope this makes sense.
Thanks again!
Paul
Once you do the rs.update you're good to go, there's no delay to worry about. However, if you're writing new records you should follow the rs.update with - rs.bookmark=rs.lastmodified
Jim
NeoPa 32,556
Expert Mod 16PB pwag
"Basically, can I pull out a value from the table I just wrote to in the same sub procedure?"
Simply put - Yes. As Jim says, once the .Update() has been executed the table contains the data.
There is a caveat to that, which is that this behaviour would be modified if you were using transactions in your code. In this latter case the data would be ready to access only when the transaction is completed. I suspect that isn't an issue for you though.
Thanks Jim and NeoPa,
NeoPa,
Could you briefly explain what you mean by "transactions?" You're correct, it probably doesn't apply here though.
Paul
Paul, transaction processing is a way to start a posting process, for example, and un-do whatever is done if the process does not finish completely without error. You do it all or you do nothing.
Here is a good MS article on the topic. http://msdn.microsoft.com/en-us/libr...ffice.12).aspx
Jim
NeoPa 32,556
Expert Mod 16PB
That about says it Paul. Not much I can add to that.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: aish |
last post by:
I want to send email using sql stored procedure.my code is work fine in my local sqlserver account. when I use my online sql server it display this error.
EXECUTE permission denied on object...
|
by: Rami |
last post by:
Dear all,
i would like to ask if it possible to fill a dataset using one stored
procedure,
for example:
we have two tables ( emp ) and ( Dept )
can i use the following stored procedure...
|
by: Justin |
last post by:
I am trying to do a simple update of a database using a stored procedure. I
have get the following error when executing the code:
"Procedure or function UpdateDetails has too many arguments...
|
by: Matthew Curiale |
last post by:
I am trying to create a search page for a database that will display
in a repeater, using a stored procedure. The page_load is fine, and
calls/displays all rows from the db just fine. When I input...
|
by: george |
last post by:
Hi world!
Anyone experienced building gridview in Oracle environment using stored
procedures, please help!
Right now, I have issues using Oracle SP, I spent a whole day on this
and still...
|
by: rsdev |
last post by:
Hi,
I'm trying to find a way to create an XML file from an SQL table row using a stored procedure.
This is what I have so far, but it is incomplete;
CREATE PROCEDURE dbo.xml_header...
|
by: svgeorge |
last post by:
I want to update several tables using one stored procedure.
How can i do this I mean the syntax.etc. declaration etc.
I know the basic syntax as below
CREATE PROCEDURE <Procedure_Name, sysname,...
|
by: bprocopio |
last post by:
Please help. I'm stumped.
I need to create a dynamic variable in a procedure that will be used
to update a variable of the same name in a table. i.e. the name in
tblAnalysisScores are...
|
by: santhanalakshmi |
last post by:
Hi,
Any one, please give me a clear description of the Stored Procedure.What is the main benefits of using a Stored Procedure in SQL ? Thanks in advance
|
by: dosa |
last post by:
hello
can i ask how can i put a variable copy in update query
if i write this give me a wrong:
sql="UPDATE book_info SET num_copies="copy" "+
" where num="+Request.form("No_book");...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |