R
ryguy7272
Here’s the code:
Private Sub Post_Click()
Dim err As Integer
Dim cnn1 As ADODB.Connection
Dim rstcontact As ADODB.Recordset
Dim strCnn As String
'if no errors insert data
If err < 1 Then
' Open a connection.
Set cnn1 = New ADODB.Connection
mydb = "C:\Pivot Trading System.accdb"
strCnn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & mydb
cnn1.Open strCnn
' Open contact table.
Set rstcontact = New ADODB.Recordset
rstcontact.CursorType = adOpenKeyset
rstcontact.LockType = adLockOptimistic
rstcontact.Open "Options", cnn1, , , adCmdTable
'get the new record data
rstcontact.AddNew
rstcontact!OptionNo = OptionNo
rstcontact!TicketNo = TicketNo
rstcontact!Side = Side
rstcontact!Symbol = Symbol
rstcontact!Quantity = Quantity
rstcontact!Strike = Strike
rstcontact!Call_Put = Call_Put
rstcontact!Price = Price
rstcontact!Exchange = Exchange
rstcontact!Approved = Approved
rstcontact!DateAdd = Now()
rstcontact.Update
' Show the newly added data.
MsgBox "New Post: " & rstcontact!OptionNo & " " &
rstcontact!TicketNo & " has been successfully added"
'close connections
rstcontact.Close
cnn1.Close
Else
MsgBox "An Error has occurred, please check and try again"
End If
End Sub
When I run the code, I get a run-time error:
Multiple-step OLE DB operation generated errors. Check each OLE DB status
value, if available. No work was done.
First Question:
In my Options table, ‘Approved’ is Data Type Yes/No. On the Form, I have a
CheckBox named ‘Approved’. How do I convert this value on the Form to a
DataType that the Table will recognize?
Second Question:
Also, the DB is working from my C-drive now, as evidenced here:
mydb = "C:\Pivot Trading System.accdb"
This DB will soon go on a network. Will I split the DB, as discussed in
this link?
http://www.access-experts.com/default.aspx?selection=TutorialSplitDB&sm=18
Then, have each front-end on the C-drive and still use that line of code:
mydb = "C:\Pivot Trading System.accdb"
I guess I don’t understand how Access will ‘know’ whether to go to the
network-drive or the C-drive. I’ve never done this before so I’m looking for
some advice as to how to proceed.
Thanks!
Ryan--
Private Sub Post_Click()
Dim err As Integer
Dim cnn1 As ADODB.Connection
Dim rstcontact As ADODB.Recordset
Dim strCnn As String
'if no errors insert data
If err < 1 Then
' Open a connection.
Set cnn1 = New ADODB.Connection
mydb = "C:\Pivot Trading System.accdb"
strCnn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & mydb
cnn1.Open strCnn
' Open contact table.
Set rstcontact = New ADODB.Recordset
rstcontact.CursorType = adOpenKeyset
rstcontact.LockType = adLockOptimistic
rstcontact.Open "Options", cnn1, , , adCmdTable
'get the new record data
rstcontact.AddNew
rstcontact!OptionNo = OptionNo
rstcontact!TicketNo = TicketNo
rstcontact!Side = Side
rstcontact!Symbol = Symbol
rstcontact!Quantity = Quantity
rstcontact!Strike = Strike
rstcontact!Call_Put = Call_Put
rstcontact!Price = Price
rstcontact!Exchange = Exchange
rstcontact!Approved = Approved
rstcontact!DateAdd = Now()
rstcontact.Update
' Show the newly added data.
MsgBox "New Post: " & rstcontact!OptionNo & " " &
rstcontact!TicketNo & " has been successfully added"
'close connections
rstcontact.Close
cnn1.Close
Else
MsgBox "An Error has occurred, please check and try again"
End If
End Sub
When I run the code, I get a run-time error:
Multiple-step OLE DB operation generated errors. Check each OLE DB status
value, if available. No work was done.
First Question:
In my Options table, ‘Approved’ is Data Type Yes/No. On the Form, I have a
CheckBox named ‘Approved’. How do I convert this value on the Form to a
DataType that the Table will recognize?
Second Question:
Also, the DB is working from my C-drive now, as evidenced here:
mydb = "C:\Pivot Trading System.accdb"
This DB will soon go on a network. Will I split the DB, as discussed in
this link?
http://www.access-experts.com/default.aspx?selection=TutorialSplitDB&sm=18
Then, have each front-end on the C-drive and still use that line of code:
mydb = "C:\Pivot Trading System.accdb"
I guess I don’t understand how Access will ‘know’ whether to go to the
network-drive or the C-drive. I’ve never done this before so I’m looking for
some advice as to how to proceed.
Thanks!
Ryan--