By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,506 Members | 2,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,506 IT Pros & Developers. It's quick & easy.

Exporting the results of a module into an already created field in another table

P: 153
Okay so the following is a question I posted clarify what I'm trying to do here...I simply want the printed output to be put into a new field in a different table that's already created as recSet2...I'm assuming this is relatively simple and my syntax just is incorrect or perhaps the way I'm opening my connections allows for a read only connection? Any help would be much appreciated. Thanks.

Hey guys...the following code doesn't seem to work refering to the line

Originally Posted by
recSet2.Fields("DateDifference") = UntilCompletion

It says the field is not updatable...I've 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):

Originally Posted by
Public Function DaysToCompletion() As Long

'Opening tblContracts as recSet1 and recSet2
Dim con1 As ADODB.Connection
Dim con2 As ADODB.Connection
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 "tblContracts", 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
'someone else would have declared recSet1.Open
'"tblWhateverYourTableNameIs", con1 which means
'connection1 and then to open a field in that recordset you type
x = 0

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
x = (x + 1)

'Clearing recSet1 and Con1 (Connection1)
Set con1 = Nothing
Set con2 = Nothing
Set recSet1 = Nothing
Set recSet2 = Nothing

End Function
Dec 18 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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