Anyone Can Kindly Help Me With This?
May 2, 2007
I tried this code and get an error but it can insert into database which the Subject and Problem_Type in database with data Testing, Testing.
Before this my database was empty with no records.
Sub Test_Click()
Dim ADOConn
Dim RS
Dim strSQL
Const adStateOpen = 1
Set ADOConn = CreateObject("ADODB.Connection")
ADOConn.Provider = "Microsoft.JET.OLEDB.4.0"
ADOConn.Open = "C:UsersintermDocumentsDatabaseTask Data.mdb"
Set RS = CreateObject("ADODB.Recordset")
strSQL = "INSERT INTO Data (Subject, Problem_Type) VALUES ('Testing', 'Testing')"
RS.Open strSQL, ADOConn
RS.Close
End Sub
After this I check the database, the database shows:
ID Subject Problem_Type
1 Testing Testing
I find it wierd how come it can insert successfully but shows a msg saying:
"Item cannot be found in the collection corresponding to the requested name or ordinal."
P.S. This is link to Outlook. Thanks in advance.
View Replies
Sep 17, 2004
halloo everybody
Here is my code to check an excel sheet wether it is open or not.
It is working good in the following situations.
1.if the excel file is not yet opened. then it is opening and bringing a value from some cell of the sheet1.
2.If the file is already opened and not yet closed. it is not opening again it is understanding that the file is already openrd and bringing the cell value.
3.It is working when it is closed by the user and again clicked the button to open. It is opening and bringing the value.
4.NOW the problem starts.
IT IS NOT WORKING , If I click the button again to open. It is opening another copy of the same file. I did't understand why is it working perfectly? before I close the file and not working if I close the File.
please kindly check my code and respond to me .
here is my code but it is not working when the file is already opened.
Private sub Cmd_Click()
Dim XL As New Excel.Application
Dim wbk As New Excel.Workbook
Dim ws As New Excel.Worksheet
WorkBookName = "Book2.xls"
If Not WorkbookOpen(WorkBookName) Then
chk = 1
Set wbk = XL.Workbooks.Open("C:Dokumente und EinstellungenKiran KarnatiDesktopEXCELBook2.xls")
Else
Set wbk = Workbooks(WorkBookName)
End If
Set ws = wbk.Worksheets("Sheet1")
If chk = 0 Then
With ws
Label48.Caption = .Cells(1, 2).Value
.Cells(1, 3).Select
End With
Else
With ws
Text49.Value = .Cells(1, 2).Value
End With
End If
XL.Visible = True
Set SA = Nothing
Set XL = Nothing
Set wbk = Nothing
End Sub
_________________________________________________
Function WorkbookOpen(WorkBookName As String) As Boolean
'Returns TRUE if the workbook is open
WorkbookOpen = False
On Error GoTo WorkBookNotOpen
If Len(Excel.Workbooks(WorkBookName).Name) > 0 Then
WorkbookOpen = True
Exit Function
End If
WorkBookNotOpen:
End Function
Thank you.
Kiran.
View 1 Replies
View Related