R
ryguy7272
Unrecognized database format ‘C:\Trading System’
I’m working in 2007 (finally took the leaf of faith). Why would I get the
error described above? My code is below:
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:\Trading System.accdb"
strCnn = "Provider=Microsoft.Jet.OLEDB.4.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!Month = Month
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
I think the problem is coming from here:
mydb = "C:\Trading System.accdb"
I am referencing Microsoft ActiveX Data Objects 2.8 Library
I tried to reference Microsoft DAO 3.6 Object Library because this is what I
had when I used this code in Access 2002. This must be a simple fix, right.
One of the references is not correct?
Also, I now have this saved on my C-drive. How can I make sure the Form
will write to the Table no matter where the database is saved? I’m giving
this file to a friend when I am done with it. I think he is going to put it
on his corp. network (intranet). Is there some way to set this up so the
database doesn’t have to be saved to a specific place? I know a few people
in his office will use it. I know he will not save the file on hid cC-drive,
like I did. Any thoughts on this?
Thanks so much!
Ryan---
I’m working in 2007 (finally took the leaf of faith). Why would I get the
error described above? My code is below:
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:\Trading System.accdb"
strCnn = "Provider=Microsoft.Jet.OLEDB.4.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!Month = Month
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
I think the problem is coming from here:
mydb = "C:\Trading System.accdb"
I am referencing Microsoft ActiveX Data Objects 2.8 Library
I tried to reference Microsoft DAO 3.6 Object Library because this is what I
had when I used this code in Access 2002. This must be a simple fix, right.
One of the references is not correct?
Also, I now have this saved on my C-drive. How can I make sure the Form
will write to the Table no matter where the database is saved? I’m giving
this file to a friend when I am done with it. I think he is going to put it
on his corp. network (intranet). Is there some way to set this up so the
database doesn’t have to be saved to a specific place? I know a few people
in his office will use it. I know he will not save the file on hid cC-drive,
like I did. Any thoughts on this?
Thanks so much!
Ryan---