aktharshaik 16 Posting Whiz

when u want only to read the data use in readonly mode. if u want to manipulate the data then it should be opened in dynamic mode.

try to get some documentation on ADODB usage of Connection, Command, Recordset and Parameter

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

open the recordset as adOpenDynamic, adLockOptimistic

adOpenKeyset, adLockReadOnly opens the recordset in readonly mode and prevents any changes to the data.


Mark the solved threads as solved if they are solved.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Hi! Smile4Ever,

Exactly as Jx_Man said, elaborate your request dear. can't figure out ur requirement. what tabs? Any sample code u got, tried anything yet?

Never tried = Never Know
So, Please do something before post your thread.

A nice thing to ponder upon.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Any problems get back. If solved mark the thread as solved

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Make changes to ur database. make it more easier to query. set the id fields to numeric.

Keep looking. I'll post the modified version of ur project along with the modified database later.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

I have attached the modified version of ur project. Have a look at it.
Dereference the DAO Library in references. It is not required. ADO is very flexible to use.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Use the Package and Deployment wizard to create the Setup Package from the source system where u have developed this project.
This addin is a part of Microsoft Visual Basic.

1. Open ur project
2. Select Add-Ins -> Add-In Manager... option
3. Select the Package & Deployment Wizard
4. Put a check for Loaded/Unloaded and Load on Startup check boxes.
5. Click Ok.

Now u can find the Package & Deployment Wizard menu option in the Add-Ins menu. Click it and follow the instructions. This wizard will automatically identify all the required object, components and dlls for the project. except for user created files like ur database files, icon files etc. which if u want can manually add them in, i beleive 4/5 step of the wizard

Once the setup package folder is created, copy it to CD or pendrive and perform the setup process in the target computer.


Hope this helps u. Try it and if any problems get back to us.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Plz if u can post the little code u have tried and failed, what database u r using, tables and their field names involved in this, then it will b easy and quick for us to help u with the problem.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

As suggested by wrappingduke the DTPicker and the MonthView controls are comfortable to use.

Another suggestion is that if u r using VB6.0 and have not applied the Service Pack 6, do it now because some functionalities related to these controls have been rectified and patched.

The Component Reference Name is
Micorosoft Windows Common Controls-2 6.0 (SP6)

and the file is

MSCOMCT2.OCX

If the entry cannot be found in the Components Tab, u can browse for the above file from the components tab. The file MSCOMCT2.OCX resides in your "\WINDOWS\System" folder in Windows installed DRIVE for Windows 95,98 or Millenium editions
and "\WINDOWS\System32" folder IN Windows installed DRIVE for XP.
or sometimes
"\WINNT\SYSTEM32" if Windows NT, 2003 etc.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Dear,

As far as the connection to the db is concerned, u need to change the code at all places wherever u r connecting to the Access DB.
if u r using Jet Database Driver for Access, u need to change it to the Microsoft Foxpro Driver.

Coming to the SQL Queries most of the queries used in MS-Access work in FoxPro 2.6 for DOS.
Open your Foxpro IDE and try all the Possible Types of Queries u r using for MS-Access in the FoxPro command window once. Check out what type of queries r not working and just replace those.

Another Suggestion is that if u should and must have the flexibility of changing the Databases now & then, I suggest u that now is the time to work out on that in a more innovative method.

Create a database which stores the Types of Databases, Their Connection Strings, Current DB Type in use, SQL Queries, every possible variable content that ur project may be using. So that u can switch to the required one at any instance. Even this will pave the way for even if u r trying to go to some other database in future, like oracle, sql server etc. At that instance u will have very less work to do.

Of course all this requires a sufficient amount of time and man-power proportional ti the concern of the duration u have got to complete this.

Will try …

aktharshaik 16 Posting Whiz

Is ur problem solved. If solved then mark the thread as solved.

Anything else u may need feel free to ask anytime.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

I AM UPLOADING A SAMPLE PROJECT HERE FOR UR REFERENCE.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

The hyperlink datatype adds a character '#' in the beginning and ending of the field value.

hence use the hLinkFile variable which holds the value of the Description field by eliminating the unnecessary # character using the Mid function

check if the file exists in the given path in the hLinkFile variable, and if yes then go for opening it and display its data.

put all the variables in the same procedure itself.

Imp: Add the following references.

1. Microsoft ActiveX Data Object 2.1 Library
2. Microsoft Scripting Runtime Library

Dim db As ADODB.Connection
    Dim rst As ADODB.Recordset
    Dim FSO As New FileSystemObject
    Dim FL As TextStream
    Dim hLinkFile As String

    Set db = New ADODB.Connection
    Set rst = New ADODB.Recordset
    db.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & App.Path & "\database.mdb"

rst.Open "SELECT DESCRIPTION FROM EQUIPMENT ", db, adOpenKeyset, adLockReadOnly

    If rst.BOF = False Then
        hLinkFile = Mid(rst!Description, 2, Len(rst!Description) - 2)
        If Dir(hLinkFile) <> "" Then
            Set FL = FSO.OpenTextFile(hLinkFile, ForReading, False)
            Text1.Text = ""
            While Not FL.AtEndOfStream
                Text1.Text = Text1.Text & FL.ReadLine
            Wend
            FL.Close
        End If
    End If

    If rst.State Then rst.Close
    Set rst = Nothing

    If db.State Then db.Close
    Set db = Nothing

    Set FL = Nothing
    Set FSO = Nothing

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

plz post the fieldnames and the sample data in those fields in the EQUIPMENT table

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

use the following statement in declaring variables
Make sure to add Microsoft ActiveX Data Objects 2.1 Library in references

Dim db as New ADODB.Connection
Dim rst as New ADODB.RecordSet
Dim FSO As New FileSystemObject
Dim FL as TextStream

db.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & App.Path & "\database.mdb"

rst.open "SELECT DESCRIPTION FROM EQUIPMENT ", db, adopenKeySet, adLockReadOnly

If rst.BOF = False Then
  'open the file in the field which contains
  'the hyperlink to the textfile
  'here replace the hLinkField with the hyperlink field actually
  'in ur table

 Set FL=FSO.OpenTextFile(rst!Description, ForReading, False)
 Text1.Text = ""
 While Not FL.AtEndOfStream
  Text1.Text = Text1.Text & FL.ReadLine
 Wend
 FL.Close
End If

Set FL = Nothing
Set FSO = Nothing

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

HEY con is the database object i referenced.
i think u have to use 'db'

aktharshaik 16 Posting Whiz

PLZ POST THE ENTIRE CODE. I'LL JUST CORRECT IT OUT IF ANY MISTAKES.
ALSO UPLOAD THE DATABASE IF U CAN IN ZIP FORMAT.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

u have not closed the quotation marks dear

rst.Open "SELECT Description From Equipment", con, adopenKeySet, adLockReadOnly

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

here in this code it reads only the first record, opens the text file specified in the hyperlink column and displays its contents in the textbox.
Also note what the name of the textbox is in your form. here i have mentioned it as Text1. See that if u too have the same name of the textbox u created or anything else u might have changed the Name property of the textbox in which u r displaying the file contents.

aktharshaik 16 Posting Whiz
Dim FSO As New FileSystemObject
Dim FL as TextStream

Set db = OpenDatabase(App.Path & "\database.mdb")
Set rst = db.OpenRecordset("table") 

'If record found then
If rst.BOF = False Then
  'open the file in the field which contains
  'the hyperlink to the textfile
  'here replace the hLinkField with the hyperlink field actually
  'in ur table

 Set FL=FSO.OpenTextFile(rst!hLinkField, & _
            ForReading, False)
 Text1.Text = ""
 While Not FL.AtEndOfStream
  Text1.Text = Text1.Text & FL.ReadLine
 Wend
 FL.Close
End If

Set FL = Nothing
Set FSO = Nothing

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Run-Time error 438:
Object does not support this property or method with
rst.Open "SELECT hLinkField....." highlighted.
so, i don't know what to do!


Dear Dan,

I added a dummy SQL Query stating that u have to use your fieldname which has the hyperlink and table name which holds the hyperlink column.

replace hLinkField with the fieldname in your table
replace MyTable with the tablename in your database
if any filtering is to be done based on a particular column add the 'where' clause
or just query all the records like "Select * from table"


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Here I assume u know how to connect to your database. i have considered ADODB.Connection object "con" which is global and already attached to the database.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Ok. Plz take some time. I'll upload some sample code in a few hours. I need to prepare some documentation also for ur reference.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Open the recordset. Extract the field with hyperlink and connect it to the File System Object and TextStream

Dim rs as New ADODB.Recordset
Dim FSO As New FileSystemObject
Dim FL As TextStream

rs.Open "SELECT hLinkField FROM MYTABLE WHERE ID = 1", con,adopenKeySet, adLockReadOnly

'If record found then
If rs.BOF = False Then
  'open the file in the field which contains
  'the hyperlink to the textfile
 Set FL=FSO.OpenTextFile(rs!hLinkField, & _
            ForReading, False)
 Text1.Text = ""
 While Not FL.AtEndOfStream
  Text1.Text = Text1.Text & FL.ReadLine
 Wend
 FL.Close
End If

Set FL = Nothing
Set FSO = Nothing

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

s. u can use the file system object and textstream to open a textfile, read the data and display it in a lable or a textbox.

Add the Microsoft Scripting Runtime in the References. Create objects of the following.
FileSystemObject and TextStream


Try out these, if u still cant make the code then 'll be there to help u out.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

if u can tell some specific requirement of what exactly u need, so that we may b precise in helping u out.

Try something out like taking up a small project. say student database. adding and manipulating student records etc.

Plz have a start, then only u will be able to learn very easily.

I am sorry if i have said anything out of ur way. but my sincere advice is first make a start urself, help urself first to make us help u.
Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Dear Friend,

Also plz mark all the thread which r being solved as solved not leaving them as unanswered threads.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Check Out the Sample Project Here for resizing the window to full screen and restore it back to its original state.

Some more code for Hide/Display the title bar is also added.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Try This Code

'Put this declaration on the top of the Code Window of the form
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long,          ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Const HWND_TOP = 0
Public Const SWP_SHOWWINDOW = &H40

'Put this code in the Button_Click() event
'Or whereever u want to make the 
'screen full screen.

Dim cx As Long
Dim cy As Long
Dim RetVal As Long

' Determine if screen is already maximized.
If Me.WindowState = vbMaximized Then
    ' Set window to normal size
    Me.WindowState = vbNormal
End If

' Get full screen width.
cx = GetSystemMetrics(SM_CXSCREEN)
' Get full screen height.
cy = GetSystemMetrics(SM_CYSCREEN)

' Call API to set new size of window.
RetVal = SetWindowPos(Me.hwnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW)

Hope this solves ur problem

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

The answer 'A' is true because within a module or from another module u can call the procedure followed by its module name. but to call a function which is in another module, the module name where the function resides will be mandatory.

The Answer 'B' is true because you can call a function in another module if and only if it is declared as public.

The Answer 'C' is false because the radius and height are the arguments passed to the function and not the return values. And also a function can return one and only one value.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

U have to take another Variable

I = 1
N = 5
Do While I < N
    Cells(1,I) = N - I
    I = I + 1
Loop

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz
Dim colVar As Integer
    Dim noOfCols As Integer
    Dim colChars As String
    Dim cellAdd As String

    colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

    'This piece of code holds good 
    'for Columns upto 26 only
    'Because beyond that the col names will
    'be AA, AB, AC,...
    'Then u may have to create and array
    'using a loop to store the column names

    noOfCols = 10

    For colVar = 1 To noOfCols
        cellAdd = Mid(colChars, colVar, 1) & 1
        Range(cellAdd).Value = noOfCols - colVar + 1
    Next colVar

Hope this solves ur problem.

Dear herephishy,
plz dont break the thread. continue ur queries in the previous thread itself. so that u can get all ur related solutions in one single thread. this is just a piece of advice. hope i didn't say anything wrong


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Dear herephishy,
plz dont break the thread. continue ur queries in the previous thread itself. so that u can get all ur related solutions in one single thread. this is just a piece of advice. hope i didn't say anything wrong

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz
Dim colVar As Integer
    Dim noOfCols As Integer
    Dim colChars As String
    Dim cellAdd As String

    colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

    'This piece of code holds good 
    'for Columns upto 26 only
    'Because beyond that the col names will
    'be AA, AB, AC,...
    'Then u may have to create and array
    'using a loop to store the column names

    noOfCols = 10

    For colVar = 1 To noOfCols
        cellAdd = Mid(colChars, colVar, 1) & 1
        Range(cellAdd).Value = noOfCols - colVar + 1
    Next colVar

Hope this solves ur problem.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

There r so many ways to loop.
Try this one.

Dim colVar As Integer
    Dim colChars As String
    Dim cellAdd As String

    colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

    For colVar = 1 To 4
        cellAdd = Mid(colChars, colVar, 1) & 1
        Range(cellAdd).Value = colVar
    Next colVar

Hope this solves ur problem.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

I think u can get some clue from this following thread, please have a look at it and if solves ur need, please post the reputation of the solution to the poster hell_tej.

http://www.daniweb.com/forums/thread140360.html

Let me know if there is something else than this is what u need along with the Backend and Crystal Reports Version u r using.


Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

I guess it is c) -1

aktharshaik 16 Posting Whiz

Yes surely u can use crystal reports. What is the Database u r using? Is it MS-Access or SQL Server or other. If u r stuck up at any point just post the code at which u r stuck up with. will try to do the needful.
Also can u tell me the version of crystal reports u r using.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Hi,

Plz chk out the sample project i have given here as attachment. it may help u get some logic.
u need not query the database each time u want to search. fill the flexgrid once when form loads and then use that static data to find the rows with your search values af any required column.

Hope this may help u.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

ok. sorting out the problem. just a few minutes plz.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Ok. I think that you have the recordset declared globally and accessing the recordset in the dload procedure to fill the FlexGrid. then the problem with it is;
1. you are not opening the recordset in the cmdSearch_Click() event.
2. you are setting the recordset to nothing the the cmdSearch_Click() at the end which closes the recordset if open.


may be i can help u with this

Private Sub cmdSearch_Click()

    On Error GoTo errhan

    'Close the recordset if open first before searching
    If Not rst Is Nothing Then
         if rst.state then rst.close
        Set rst = Nothing
    End If
    'Instantiate again
    Set rst = New ADODB.Recordset

    rst.CursorLocation = adUseClient
    SQL = "Select * from profile2 where name like '" & Trim(fldSearch.Text) & "%'"
    'Open the recordset
    rst.Open SQL, con, adOpenKeyset, adLockReadOnly

    'Now u can call this procedure and get the recordset to work without error
    'because it is not yet closed
    Call dload

exitPoint:
    Exit Sub

errhan:
    MsgBox "Err No : " & Err.Number & vbCrLf & Err.Description
    'Put the error control code here to close recordset if any error occurs
    If Not rst Is Nothing Then
         if rst.state then rst.close
        Set rst = Nothing
    End If
    Resume exitPoint

End Sub


Private Sub dlload()

    MSFlexGrid1.Clear
    While Not rst.EOF
        'replace field1,field2 etc with the fields u want
        MSFlexGrid1.addItem rst!field1 & vbTab & rst!field2
        rst.MoveNext
    Wend

End Sub

hope it solves ur problem.

Regards
Shaik Akthar

aktharshaik 16 Posting Whiz

Try this.

Private Sub cmdSearch_Click()

    On Error GoTo errhan

    Set rst = New ADODB.Recordset

    rst.CursorLocation = adUseClient
    SQL = "Select * from profile2 where name like '" & Trim(fldSearch.Text) & "%'"
    rst.Open SQL, con, adOpenKeyset, adLockReadOnly

    MSFlexGrid1.Clear
    While Not rst.EOF
        'replace field1,field2 etc with the fields u want
        MSFlexGrid1.addItem rst!field1 & vbTab & rst!field2
        rst.MoveNext
    Wend

    Call dload

exitPoint:
    If Not rst Is Nothing Then
         if rst.state then rst.close
        Set rst = Nothing
    End If
    Exit Sub

errhan:
    MsgBox "Err No : " & Err.Number & vbCrLf & Err.Description
    Resume exitPoint

End Sub

can u tell me what is this dload procedure?

aktharshaik 16 Posting Whiz

Still more effective solution can be done.

First you may need to iterate through all the processes running in the memory to check whether at all if excel is running.

If it is not running then u may create the new instance of the excel application and open your file as usual.

if it is already running, then get the application handle to the excel application already open and check whether ur file to be opened is already opened or not. if yes then display "File Already Open" message, else open the file.

go for some googling at google.com for help regarding iterating through the running processes, getting the window handles of the applications and attaching them to objects, etc.

good luck.
U Work a Little, We Guide U a Little.

aktharshaik 16 Posting Whiz

Check Out this code. it may be of some help. i'll give still more effective code later on if u r not able to get what u need. try to use the logic from the sample code given here.

Option Explicit
Private xlTemp As Excel.Application
Private sFileName As String

Private Sub cmdOpen_Click()

    On Error GoTo cmdOpen_Click_Error

    Set xlTemp = New Excel.Application
    sFileName = "C:\TEST.XLS"

    If Dir(sFileName) <> "" Then
        xlTemp.Workbooks.Open sFileName
        xlTemp.Visible = True
    Else
        MsgBox "File Not Found."
    End If

cmdOpen_Click_Done:
    Exit Sub

cmdOpen_Click_Error:
    MsgBox "An Error has occured in Procedure cmdOpen_Click." & vbCrLf & Err.Number & " : " & Err.Description & vbCrLf & vbCrLf & "Contact System Administrator."
    Resume cmdOpen_Click_Done

End Sub

Private Sub cmdClose_Click()

    Dim ret As Integer
    Dim nFiles As Integer
    Dim iVar As Integer

    On Error GoTo cmdClose_Click_Error

    If Not xlTemp Is Nothing Then
        If xlTemp.Visible Then
            nFiles = xlTemp.Workbooks.Count
            For iVar = 1 To nFiles
                If UCase(xlTemp.Workbooks(iVar).Path & "\" & xlTemp.Workbooks(iVar).Name) = UCase(sFileName) Then
                    xlTemp.Workbooks(iVar).Close
                    If nFiles = 1 Then          'Confirm that no other workbooks are open and then quit
                        xlTemp.Quit
                    End If
                    Exit For
                End If
            Next
        End If
    End If

cmdClose_Click_Done:
    Exit Sub

cmdClose_Click_Error:
    MsgBox "An Error has occured in Procedure cmdClose_Click." & vbCrLf & Err.Number & " : " & Err.Description & vbCrLf & vbCrLf & "Contact System Administrator."
    If Not xlTemp Is Nothing Then
        If xlTemp.Visible Then
            xlTemp.Workbooks.Close
            xlTemp.Quit
        End If
    End If
    Set xlTemp = Nothing
    Resume cmdClose_Click_Done

End Sub
aktharshaik 16 Posting Whiz

You may still have to validate if the data entered in the input box is in the expected date format or not and then go for updating the cell in the WorkSheet. Because a mere inputbox will allow me to enter any garbage, meaningless data also.

aktharshaik 16 Posting Whiz

Confirm that the Regional Settings in the control panel also has the dd/MM/yy setting of the system whenever u r placing this excel file in another new system.

Just check out this code here. I have modified your code in Module2 in procedure Enter_FOAP()

Sub Enter_FOAP()

    Dim xDate As Date
    Sheets("Figures").Select

    ActiveSheet.Unprotect

    Range("N1").Select
    w = InputBox("Enter Voyage No. i.e. IH0603-106L")
    ActiveCell.Value = w

    Range("b6").Select
    xDate = InputBox("Enter date & time for FAOP i.e. 01/01/06 12:00", "Date Time for FAOP", Format(Now, "dd/MM/yy hh:nn"))
'    x = InputBox("Enter date & time for FAOP i.e. 01/01/06 12:00")
    ActiveCell.Value = xDate

    Range("o6").Select
    xDate = InputBox("Enter date & time for ETA Singapore i.e. 01/01/06 12:00")
    ActiveCell.Value = xDate

    Range("t6").Select
    xDate = InputBox("Enter date & time for ETA Japan i.e. 01/01/06 12:00")
    ActiveCell.Value = xDate

End Sub

regards,
Shaik Akthar

aktharshaik 16 Posting Whiz

Working with it plz wait. 'll provide the solution asap

aktharshaik 16 Posting Whiz

Check this

dinilkarun commented: Very helpful person. +1
aktharshaik 16 Posting Whiz

No. But i added a query there named CREATENEWTAB

Also check out the field names in your database and the code. i had changed the field names here by appending _Attr to last three fields, because type, value etc may be some keywords or reserved VB words.

aktharshaik 16 Posting Whiz

upload ur excel file here using the Go Advanced button to post the reply and i can try to do the needful and send it back to u.