Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to "know" which options were selected to create diferent docs...

Status
Not open for further replies.

Mcr13

IS-IT--Management
Apr 23, 2001
4
US
I have an Access form were the users can select one or many diferent types of documents that they need to create (one or many), total 6. How can I "know" which options were selected and create a diferent document for each of the selected options???
 
Well....R u using Option Group or Combo boxes or what method to select the option. I dont think that its much techincal if u r using option groups or combox box...ur code will go smewhat like this

If MyOptGp = 1 then
'Here goes first type of document code
Elseif MyOptGp = 2 then
'Here goes second type of document code
else
'Here goes third type of document code
End if

I hope I've understood ur problem...if not the give a little detail abt that.

Cheers!
Aqif

 
Thanks for your response. I'm using just check boxes to select each option. I have a question about the use of my word code, I mean, I have a procedure that crates the document but I don'tn know how to "call" it in the same form-procedure. If you want to take a look of my code:
========================================
Private Sub OK_Click()
Dim Temp As String
Dim Path As String
Dim Doc As String
Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Dim Nix
Dim Ctl As Control
Dim db As Database
Dim rst As Recordset
Dim STextmarke As String
Dim Sfeldname As String
Dim SMuss As Boolean

Doc = Me!Doc
' option1 = Create doc(s)
If Me.Options1 = 1 Then
If Me.Options1 = 1 And Me.Cover.Value = True Then
Path = CovPath
Temp = "C:\Dbedca\Templates\Cover.dot"
GoTo Create
End If
If Me.Options1 = 1 And Me.Intro.Value = True Then
Path = IntroPath
If Me!BuildType.Value = "Commercial" Then
Temp = "C:\Dbedca\Templates\IntroCom.dot"
Else
Temp = "C:\Dbedca\Templates\IntroRes.dot"
End If

GoTo Create
End If
If Me.Options1 = 1 And Me.Notice.Value = True Then
Path = NoticePath
Temp = "C:\Dbedca\Templates\Notice.dot"
GoTo Create
End If
If Me.Options1 = 1 And Me.TOC.Value = True Then
Path = tocpath
Temp = "C:\Dbedca\Templates\TOC.dot"
GoTo Create
End If
If Me.Options1 = 1 And Me.Ref.Value = True Then
Path = refpath
Temp = "C:\Dbedca\Templates\Ref.dot"
GoTo Create
End If
If Me.Options1 = 1 And Me.Project.Value = True Then
MsgBox " voy a crear project"
End If
End If

' option 2 = Edit doc(s)
If Me.Options1 = 2 Then

If Me.Options1 = 2 And Me.Cover.Value = True Then
Path = CovPath
'Edit
End If
If Me.Options1 = 2 And Me.Intro.Value = True Then
Path = IntroPath
'code to edit
End If
If Me.Options1 = 2 And Me.Notice.Value = True Then
Path = NoticePath
'Edit
End If
If Me.Options1 = 2 And Me.TOC.Value = True Then
Path = tocpath
'Edit
End If
If Me.Options1 = 2 And Me.Ref.Value = True Then
Path = refpath
'Edit
End If
If Me.Options1 = 2 And Me.Project.Value = True Then
MsgBox " voy a editar project"
End If
End If
'option3 = print document(s)
If Me.Options1 = 3 Then

If Me.Options1 = 3 And Me.Cover.Value = True Then
Path = CovPath
'GoTo ToPrint
End If
If Me.Options1 = 3 And Me.Intro.Value = True Then
Path = IntroPath
'GoTo ToPrint
End If
If Me.Options1 = 3 And Me.Notice.Value = True Then
Path = NoticePath
'GoTo ToPrint
End If
If Me.Options1 = 3 And Me.TOC.Value = True Then
Path = tocpath
'GoTo ToPrint
End If
If Me.Options1 = 3 And Me.Ref.Value = True Then
Path = refpath
'GoTo ToPrint
End If
If Me.Options1 = 3 And Me.Project.Value = True Then
MsgBox " print project"
End If

End If

Create:

On Error Resume Next
Set wordApp = GetObject(, "Word.Application.8")

If Err.Number <> 0 Then
Err.Clear
Set wordApp = CreateObject(&quot;Word.Application.8&quot;)
Else
wordApp.Activate
End If

With wordApp
.Documents.Add Template:=Temp
.WindowState = wdWindowStateMaximize

Set db = CurrentDb
Set rst = db.OpenRecordset(&quot;SELECT * FROM tblDocCenter;&quot;, dbOpenDynaset)

Do While Not rst.EOF

rst.Edit

STextmarke = rst.Fields(0)
Sfeldname = rst.Fields(1)
SMuss = rst.Fields(2)

If SMuss = True And .ActiveDocument.Bookmarks.Exists(STextmarke) = False Then
Nix = MsgBox(&quot;Bookmark &quot; & STextmarke & &quot; is missing&quot;, vbCritical + vbOKCancel, &quot;Bookmark is obligational&quot;)
If Nix = vbCancel Then
.Quit (wdDoNotSaveChanges)
Exit Sub
End If
End If

If .ActiveDocument.Bookmarks.Exists(STextmarke) = True Then
If ControlExist(Forms(Me.OpenArgs), Sfeldname) Then
.ActiveDocument.Bookmarks(STextmarke).Select
.Selection.InsertAfter Nz(Forms(Me.OpenArgs)(Sfeldname))
Else
Nix = MsgBox(&quot;wrong / missing fieldname &quot; & Chr(34) & Sfeldname & Chr(34), vbCritical + vbOKCancel, &quot;Fieldname missing, form: &quot; & Forms(Me.OpenArgs).Name)
If Nix = vbCancel Then
.Quit (wdDoNotSaveChanges)
Exit Sub
End If
End If
End If


rst.MoveNext
If rst.EOF Then Exit Do

Loop

rst.Close
.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
.Selection.WholeStory
.Selection.Fields.Update
.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
.Selection.EndOf Unit:=wdParagraph, Extend:=wdMove
.Visible = True
.WindowState = wdWindowStateMaximize
.ActiveDocument.SaveAs Chr(34) & Path & Doc & Chr(34)
.Quit
End With

Set wordDoc = Nothing
Set wordApp = Nothing

'ToEdit:
' DoCmd.OpenForm &quot;frmPleaseWait&quot;, acNormal, &quot;&quot;, &quot;&quot;, acReadOnly, acNormal
' DoCmd.RepaintObject acForm, &quot;frmPleaseWait&quot;
' Set wordDoc = GetObject(Path & Doc, &quot;Word.Document&quot;)
' wordDoc.Application.Visible = True
' DoCmd.Close acForm, &quot;frmPleaseWait&quot;

'ToPrint:
' MsgBox &quot; print&quot;

End Sub
============================================

Thanks again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top