|
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.
|
|