Hi,
I'm like a very very beginner at this, so any inputs are greatly appreciated.
What I am trying to do is add my calculated field from the form into my table. What I've done was create a query with my calculated field, then I used that query for my form. After I enter all the information, ONLY my calculated field are not stored into the table. So what I did was create a Save button with an event procedure to occur when the user click on it. When I run it, it gave me the following errors:
The database has been placed in a state by user "Admin" on machine "PC..." that prevents it from being opened or locked.
Another error is:
Item cannot be found in the collection corresponding to
the requested name or ordinal.
Here are my code:
Private Sub txtSave_Click()
Dim Conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim intID As Integer
Set dbs = CurrentDb
Set Conn = New ADODB.Connection
With Conn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source= " & dbs.Name
.Open
End With
Set rs = New ADODB.Recordset
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Open "tblTransactions", Conn, , , adCmdTable
rs.MoveLast
intID = rs![ID] + 1
rs.AddNew
rs![ID] = intID
rs![Reporting Date] = Me.[Reporting Period]
rs![Transaction Date] = Me.[Transaction Date]
rs![Maturity Date] = Me.[Maturity Date]
rs![Noon Day Rate] = Me.[Noon Day Rate]
rs![Spot Rate] = Me.[Spot Rate]
rs![Forward Rate] = Me.[Forward Rate]
rs![Contract Date] = Me.["Contract Rate"]
rs![Canadian Dollars] = Me.[Canadian Dollars]
rs![US Dollars] = Me.["US Dollars"]
rs![BankName] = Me.BankName
rs![TransactionType] = Me.[TransactionType]
rs![Confirmation] = Me.Confirmation
rs.Update
rs.Close
End Sub
My calculated field are Contract Rate, and US Dollars
Thank you so much
I'm like a very very beginner at this, so any inputs are greatly appreciated.
What I am trying to do is add my calculated field from the form into my table. What I've done was create a query with my calculated field, then I used that query for my form. After I enter all the information, ONLY my calculated field are not stored into the table. So what I did was create a Save button with an event procedure to occur when the user click on it. When I run it, it gave me the following errors:
The database has been placed in a state by user "Admin" on machine "PC..." that prevents it from being opened or locked.
Another error is:
Item cannot be found in the collection corresponding to
the requested name or ordinal.
Here are my code:
Private Sub txtSave_Click()
Dim Conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim intID As Integer
Set dbs = CurrentDb
Set Conn = New ADODB.Connection
With Conn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source= " & dbs.Name
.Open
End With
Set rs = New ADODB.Recordset
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Open "tblTransactions", Conn, , , adCmdTable
rs.MoveLast
intID = rs![ID] + 1
rs.AddNew
rs![ID] = intID
rs![Reporting Date] = Me.[Reporting Period]
rs![Transaction Date] = Me.[Transaction Date]
rs![Maturity Date] = Me.[Maturity Date]
rs![Noon Day Rate] = Me.[Noon Day Rate]
rs![Spot Rate] = Me.[Spot Rate]
rs![Forward Rate] = Me.[Forward Rate]
rs![Contract Date] = Me.["Contract Rate"]
rs![Canadian Dollars] = Me.[Canadian Dollars]
rs![US Dollars] = Me.["US Dollars"]
rs![BankName] = Me.BankName
rs![TransactionType] = Me.[TransactionType]
rs![Confirmation] = Me.Confirmation
rs.Update
rs.Close
End Sub
My calculated field are Contract Rate, and US Dollars
Thank you so much