Results 1 to 14 of 14

Thread: [RESOLVED] 2 confusing Que. (both solved by jcis)

  1. #1

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    Resolved [RESOLVED] 2 confusing Que. (both solved by jcis)

    Hello All,

    1) I have made word file as user manual of my application & I want to add it in my project (MDI form's Help menu), so howcan I do that ?

    2) Is there we can write committrans & rollback for ADO & How ?
    Last edited by shirishdawane; Feb 25th, 2006 at 04:42 AM.
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: 2 confusing Questions

    Quote Originally Posted by shirishdawane
    2) Is there we can write committrans & rollback for ADO & How ?
    VB Code:
    1. Dim cn As ADODB.Connection
    2.    
    3.     Set cn = New ADODB.Connection
    4.     cn.ConnectionString = "Your connection string"
    5.     cn.Open
    6.     'Then you can use these..
    7.     cn.BeginTrans
    8.     cn.CommitTrans  
    9.     cn.RollbackTrans

  3. #3

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    Re: 2 confusing Questions

    Suppose I am adding new record in multiple linked tables in one shot & data saved into 1st table but due to error unable to save into 2nd table then can cn.Rollback undo changes done into table1 ?
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: 2 confusing Questions

    Quote Originally Posted by shirishdawane
    Suppose I am adding new record in multiple linked tables in one shot & data saved into 1st table but due to error unable to save into 2nd table then can cn.Rollback undo changes done into table1 ?
    Yes, you can. General idea:
    VB Code:
    1. Private Sub ExecuteTransaction()
    2. Dim cn                  As ADODB.Connection
    3. Dim blnTransOpen        As Boolean
    4. Dim ConnectionLiving    As Boolean
    5.  
    6.     On Error GoTo ErrHandler
    7.     blnTransOpen = False
    8.     ConnectionLiving = False
    9.    
    10.     Set cn = New ADODB.Connection
    11.     cn.ConnectionString = "Your connection string"
    12.     cn.Open
    13.     ConnectionLiving = True
    14.        
    15.         cn.BeginTrans
    16.         blnTransOpen = True
    17.            
    18.             cn.Execute "Insert Into Table1..."
    19.             cn.Execute "Insert Into Table2..."
    20.            
    21.         cn.CommitTrans
    22.         blnTransOpen = False
    23.    
    24.     cn.Close
    25.     ConnectionLiving = False
    26.     Set cn = Nothing
    27.    
    28. Exit Sub
    29. ErrHandler:
    30.     If blnTransOpen Then
    31.         cn.RollbackTrans
    32.         MsgBox "Error when trying to Insert data", vbOKOnly + vbCritical, "Error:"
    33.     End If
    34.     If ConnectionLiving Then
    35.         cn.Close
    36.         Set cn = Nothing
    37.     End If
    38. End Sub
    Last edited by jcis; Feb 25th, 2006 at 02:38 AM.

  5. #5

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    2 confusing Questions(1 solved)

    Thanx jcis , but what about 1st que. ? if you know the answer, ofcourse.
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

  6. #6
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: 2 confusing Questions(1 solved)

    I think you need OLE to add a Word document to your Form, I never used Ole, just opened word or Excel files from VB, but that's different than what you need.
    Maybe it's not a good idea to add a word document, If I would have to add help to my program, I would use a RichTextBox, it accepts Formatting, or maybe the Advanced label control that Joacim Andersson added to VB Codebank.
    I think the real problem about Word, besides that OLE insertion you need, is that it won't work if the user hasn't word installed in that PC.
    Last edited by jcis; Feb 25th, 2006 at 02:48 AM.

  7. #7

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    Re: 2 confusing Questions(1 solved)

    Thanx for your valuable information.
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

  8. #8
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: 2 confusing Questions(1 solved)

    Quote Originally Posted by shirishdawane
    Thanx for your valuable information.
    You're welcome

  9. #9

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    Re: 2 confusing Questions(1 solved)

    [QUOTE=jcis]Maybe it's not a good idea to add a word document, If I would have to add help to my program, I would use a RichTextBox, it accepts Formatting, or maybe the Advanced label control that Joacim Andersson added to VB Codebank./QUOTE]

    Hello jcis but I have searched Code Bank forum but unable to find thread which you have mentioned if you know the link then please sende it across.
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

  10. #10
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: 2 confusing Questions(1 solved)

    Quote Originally Posted by shirishdawane
    Hello jcis but I have searched Code Bank forum but unable to find thread which you have mentioned if you know the link then please sende it across.
    Ok, this is the thread..
    http://www.vbforums.com/showthread.php?t=379724
    But now I realize that you'll need to scroll your document and don't know if that control supports scrolling. You can do it if you use a RichTextBox.

    I think a Richtextbox would be the best option then, but I've just tryied to insert an OLE object and it's easy, but again, I don't know how it should be programmed to be scrolled.If you want to try, just select the OLE component in the tool window and drag it to your Form, it will show its properties, then select browse, and select your DOC file there.
    Last edited by jcis; Feb 25th, 2006 at 04:05 AM.

  11. #11

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    Re: 2 confusing Questions(1 solved)

    Quote Originally Posted by jcis
    I don't know how it should be programmed to be scrolled.
    I have done as per you have said & geuss what when you double click on OLE object at runtime then linked Word file is getting open. So no need to write anything for OLE object scrolling.
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

  12. #12
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: [RESOLVED] 2 confusing Que. (both solved by jcis)

    The RichTextBox is the best option, this will open and show your word documents with scrollbars..

    1) In word, save your documents as RTF, it gives you that option when you click Save As..

    2) Add Microsoft Rich TextBox control 6.0 to your project. Drag it to the form and in Scrollbars property select both. Right click the control, properties and select From File, there you load your RTF file.

    That's all, you don't even need code, and you can use that documents you created with Word.

    EDIT Oh ok, you did it with OLE, you can try also this option to see how it works, then use the one you like the most.
    Last edited by jcis; Feb 25th, 2006 at 05:02 AM.

  13. #13

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    Re: [RESOLVED] 2 confusing Que. (both solved by jcis)

    Hey jcis really thanx from heart, today I really learn so many things from you. Keep guiding in future also. Thank you once again.
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

  14. #14
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: [RESOLVED] 2 confusing Que. (both solved by jcis)

    You're welcome mate

    ps: I forgot, set RichTextBox's Locked property to True, so the control won't be editable for users.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width