Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This forum is the most helpful site I've ever used. I used to use Deja.com; but, this site is better - hands down!..."

Geography

Where in the world do Tek-Tips members come from?
Dude0510 (IS/IT--Management)
14 Aug 08 13:11
I am using FormDocs 7.6.1. Currently I use 2 buttons out of the Scrapbook section of FormDocs "Open Local Document (HYPERLINK) and the other "Copy Data from one Form to Another" here is the code for both:
Private Sub BTN_LOCALDOC_Click ()
Dim URL As String

' Displays the target document in its own application.
' Replace the sample URL with your own URL in the form of
' file://path\filename.extension.

    On Error Goto Bad

    URL = "file://Z:\Forms\DayWorks\DayWorksEnvelope.fdd"
    URL = InputBox("Enter a pathname for the document to display and click OK.", "Open Local Document", URL)
    If (0 = Len(URL)) Then
        Exit Sub
    End If
        
    Application.Hyperlink(URL)
    Exit Sub

Bad:    
    MsgBox("Hyperlink Failed: " & Error(), 16)    
    
End Sub
__________________________________________________________
' This routine copies data from a source form to a destination form.
' Copying is done on a field by field basis where source and destination field names match
' and destination field is the same type as, or can be converted to, the source field type.
'
' 05/07/07 - v1.1
' Fixed bug in loop; added test 'Set objFldDest = Nothing'
' 06/19/02 - v1.0
'

Private Sub BTN_COPYFORM_Click ()
Dim I As Integer
Dim iCount As Integer
Dim iIndex As Integer
Dim sNum As String
Dim sNames(10) As String
Dim sForms As String
Dim objFrmDest As Formdocs.Form
Dim objFldSrc As Formdocs.Field
Dim objFldDest As Formdocs.Field

    On Error Goto Bad
    
    ' Ensure other forms are open & available to copy to:
    If (Forms.Count < 2) Then
        MsgBox("You must first open the other form(s) you want to copy to.", 16)
        Exit Sub
    End If
    
    sForms = ""
    iCount = 0
    ' Enumerate Forms Collection and build a string of names of other open forms.
    For Each objFrmDest In Forms
        If (objFrmDest.Name <> Thisform.Name) Then
            iCount = iCount + 1
            sForms = sForms & iCount & " - " & objFrmDest.Name & vbCrLf    
            sNames(iCount) = objFrmDest.Name
        End If    
    Next
    
Getnum:    
    sNum = InputBox("Enter the number of the form you want to copy to: "
                  & vbCrLf
                  & vbCrLf
                  & sForms, "Copy to Form", "1")
    If (Len(sNum) = 0) Then
        Exit Sub
    End If
    If Not IsNumeric(sNum) Then
        Beep
        Goto Getnum
    Else ' Range-check:
        If (CInt(sNum) > iCount) Or (CInt(sNum) < 1) Then
            Beep
            Goto Getnum
        End If    
    End If        
    
    
    iCount = 0
    Set objFrmDest = Forms(sNames(CInt(sNum)))
    
    On Error Resume Next
    ' Copy all fields. Assume Type conversion where possible.
    For Each objFldSrc In Thisform.Fields
         Set objFldDest = Nothing
        Set objFldDest = objFrmDest.Fields(objFldSrc.Name)
        If (objFldDest <> Nothing) Then
            For I = 1 To objFldSrc.CellCount
                If (I <= objFldDest.CellCount) Then
                    objFldDest.Value(I) = objFldSrc.Value(I)
                    iCount = iCount + 1
                End If
            ' else do nothing    
            Next I
        End If     
    Next objFldSrc
    MsgBox("Copied " & iCount & " matching fields to " & objFrmDest.Name, 64)
    Exit Sub

Bad:
    MsgBox("Copy to Form " & sNames(CInt(sNum)) & ": " & Error(), 16)    
End Sub

What I would like to do is to combine these two buttons into 1. Can someone tell me if this is possible.

 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close