Hey guys...the following code doesn't seem to work refering to the line
recSet2.Fields( "DateDifference ") = UntilCompletion
It says the field is not updatable...I'v e never updated a table from a module before so I'm not sure if I am doing this right but the code is pasted below (the variable 'x' has nothing to do with anything as of now, it's something I will need later)(also no need to read the commentary it's more for my own purposes since this is still a learning experience for me):
Public Function DaysToCompletio n() As Long
'Opening tblContracts as recSet1 and recSet2
Dim con1 As ADODB.Connectio n
Dim con2 As ADODB.Connectio n
Dim recSet1 As ADODB.Recordset
Dim recSet2 As ADODB.Recordset
Set con1 = CurrentProject. Connection
Set con2 = CurrentProject. Connection
Set recSet1 = New ADODB.Recordset
Set recSet2 = New ADODB.Recordset
recSet1.Open "tblContrac ts", con1
recSet2.Open "tbldtdiff" , con2
Dim x As Long
'Declaring UntilCompletion as the amount of days until completion
Dim UntilCompletion As Long
'Looping until EOF (until the last record for EndDate in tblContracts... so
'someone else would have declared recSet1.Open
'"tblWhateverYo urTableNameIs", con1 which means
'connection1 and then to open a field in that recordset you type
'recSet1.Fields ("fieldname" ))
x = 0
recSet1.MoveFir st
Do Until recSet1.EOF
' End Date must be in quotes or will not work
UntilCompletion = DateDiff("d", Date, recSet1.Fields( "EndDate"))
Debug.Print UntilCompletion
recSet2.Fields( "DateDifference ") = UntilCompletion
recSet1.MoveNex t
x = (x + 1)
Loop
'Clearing recSet1 and Con1 (Connection1)
recSet1.Close
recSet2.Close
con1.Close
con2.Close
Set con1 = Nothing
Set con2 = Nothing
Set recSet1 = Nothing
Set recSet2 = Nothing
End Function
9 1879 MMcCarthy 14,534
Recognized Expert Moderator MVP
Try this ... -
recSet2.Edit
-
recSet2.Fields("DateDifference") = UntilCompletion
-
recSet2.Update
-
Mary
Thanks...I have tried this but it has not worked for me...do I need a special library to run this code? It says it's out of range of, at least, my declared public variable?
Well actually this is the exact error message:
Method or data member not found (Error 461)
but it refers to that first line of code that declares the public variable...this is something that only happens once I enter this code
this has been my solution so far
Do While FigureOut=False
SlamHeadOnDesk
Loop
Furthermore I guess I don't have the option of .edit but rather .editmode and when I try that I get the error "Invalid Use of Property"
Ahh finally I figured it out
Here is the code...I figure it may be useful in some way or another...espec ially considering this line "recSet2.Op en "tbldtdiff" , con2, adOpenKeyset, adLockOptimisti c" is very confusing...the re aren't enough places that explain these options when opening a recordset...I just went through all the options and it worked finally....what the heck does lock optimistic mean? lol
Option Compare Database
Public Function DaysToCompletio n() As Long
'Opening tblContracts as recSet1
Dim con1 As ADODB.Connectio n
Dim con2 As ADODB.Connectio n
Dim recSet1 As ADODB.Recordset
Dim recSet2 As ADODB.Recordset
Set con1 = CurrentProject. Connection
Set con2 = CurrentProject. Connection
Set recSet1 = New ADODB.Recordset
Set recSet2 = New ADODB.Recordset
recSet1.Open "tblContrac ts", con1
recSet2.Open "tbldtdiff" , con2, adOpenKeyset, adLockOptimisti c
Dim x As Long
'Declaring UntilCompletion as the amount of days until completion
Dim UntilCompletion As Long
'Looping until EOF (until the last record for EndDate in tblContracts... so
'someone else would have declared recSet1.Open
'"tblWhateverYo urTableNameIs", con1 which means
'connection1 and then to open a field in that recordset you type
'recSet1.Fields ("fieldname" ))
x = 0
recSet1.MoveFir st
Do Until recSet1.EOF
' End Date must be in quotes or will not work
UntilCompletion = DateDiff("d", Date, recSet1.Fields( "EndDate"))
Debug.Print UntilCompletion
recSet2.AddNew
recSet2.Fields( "DateDifference ") = UntilCompletion
recSet2.Update
recSet1.MoveNex t
x = (x + 1)
Loop
'Clearing recSet1 and Con1 (Connection1) and recSet 2 and Con1
recSet1.Close
recSet2.Close
con1.Close
con2.Close
Set con1 = Nothing
Set con2 = Nothing
Set recSet1 = Nothing
Set recSet2 = Nothing
End Function
NeoPa 32,573
Recognized Expert Moderator MVP
Thanks...I have tried this but it has not worked for me...do I need a special library to run this code? It says it's out of range of, at least, my declared public variable?
Well actually this is the exact error message:
but it refers to that first line of code that declares the public variable...this is something that only happens once I enter this code
Where is DaysToCompletio n() defined?
You declare a reference to it but it doesn't seem to be defined anywhere.
NeoPa 32,573
Recognized Expert Moderator MVP
what the heck does lock optimistic mean? lol
LockTypeEnum
Specifies the type of lock placed on records during editing.
Constant Value Description
adLockBatchOpti mistic 4 Indicates optimistic batch updates. Required for batch update mode. adLockOptimisti c 3 Indicates optimistic locking, record by record. The provider uses optimistic locking, locking records only when you call the Update method. adLockPessimist ic 2 Indicates pessimistic locking, record by record. The provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately after editing.
adLockReadOnly 1 Indicates read-only records. You cannot alter the data.
adLockUnspecifi ed -1 Does not specify a type of lock. For clones, the clone is created with the same lock type as the original.
This should help explain that.
Yep, thanks...I posted the entire module here: http://www.thescripts.com/forum/thread579007.html
thought someone could use it in the future
once I figured that lock stuff out I just had one of those moments when everything came together and code started spewing out of my fingers and sweat glands....heck I even peed the longest do while loop ever ....I feel empowered!!!!
NeoPa 32,573
Recognized Expert Moderator MVP
Yep, thanks...I posted the entire module here: http://www.thescripts.com/forum/thread579007.html
thought someone could use it in the future
once I figured that lock stuff out I just had one of those moments when everything came together and code started spewing out of my fingers and sweat glands....heck I even peed the longest do while loop ever ....I feel empowered!!!!
lol
Good for you Kosmos.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jason |
last post by:
Let's say I have an html form with 20 or 30 fields in it. The form
submits the fields via POST to a php page which updates a table in a
database with the $_POST vars. Which makes more sense?
1) simply UPDATING the values for all fields in the table, whether or
not any particular field has actually changed
2) running a second SELECT statement and comparing the $_POST vars to
the returned values, and only UPDATING those that have...
|
by: Jaime Wyant |
last post by:
*long post alert!*
Can anyone give me some pointers on writing "self-updating" python
programs? I have an application that is almost ready for beta
testing. I want to be able to fix any bugs and push the updates out.
I have a *very vague* idea of how to attack this. The client will
have an auto-update feature that will hit the webserver via xml-rpc,
asking for updates. The server responds, sending back any updated
modules.
|
by: George |
last post by:
The flow of my app is as follows
1) Pull up an order and change the quantity of a textbox item. (Ex: change the quantity from 1 to 2
2) Click on the Update button
3) When the page posts back you should see the updated quantity of the item. (by the way, in some cases there will be multiple lines for an order...this is where the problem comes in.
What happens is that the process works...for the first row of data only. I need the app to...
|
by: amber |
last post by:
Hello
I can't get my update command to work..
I've used the sqlDataAdapter wizard to create a dataAdapter sqlDA_CB_LP, and it created the 'UPDATE' code as follows
Me.sqlDA_CB_LP.UpdateCommand = Me.SqlUpdateCommand
Me.SqlUpdateCommand4.Connection = Me.SqlConnection
Me.SqlUpdateCommand4.Parameters.Add(New System.Data.SqlClient.SqlParameter("@STR_COMMENT", System.Data.SqlDbType.NVarChar, 1073741823, "STR_COMMENT")
|
by: Chris A via AccessMonster.com |
last post by:
I have an interesting problem that I have yet to come accross that I can't
change data structure on because it is an export from filemaker I am
reformatting for another dept. anyway. I have a table like so...
Table 1
Field1 Field2 Field3
E1 April 2006 AA, BB, CC
E2 April 2006 AA, BB, CC,DD, EE
E3 April 2006 AA, BB
| |
by: TORQUE |
last post by:
Hi,
Im wondering if anyone can help me with a problem.
I have a form with more than 50 unbound fields.
Some of the fields will be blank from time to time.
This seems to be where im having trouble.
I have tried keeping some of the fields bound and when I use the save button
it has been saving as 2 different records. This is unacceptable.
This is what I have, can anyone help me out with this?
|
by: bill |
last post by:
In an application I am writing the user can define a series of
steps to be followed. I save them in a sql database using the
field "order" (a smallint) as the primary key.
(there are in the range of 20 steps)
On the admin page the steps are listed, in "order" order and the
user can create new steps and assign an order and all is well.
The problem may come in using a renumber function which should
take the steps in their current order...
|
by: =?Utf-8?B?VmFuZXNzYQ==?= |
last post by:
Hi All!
I am with a situation where I am not getting the right updating to the
form's fields. The situation is the following one:
I have one combobox and one textbox. I am using the CurrentChanged event of
the BindingSource of the combobox to update the textbox. When selecting an
item in the combobox or when selecting a row in the grid, it is updating the
textbox correctly. The problem is when I apply a filter in the grid, and then...
|
by: MLH |
last post by:
Utilities to recover tbl removed from
TABLE tab of database window with
the DELETE key?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |