corngopher
03-06-2005, 02:31 PM
Good afternoon,
I am trying to get this bit of code to loop through and see which checkboxes are checked and pull up the information associated with it. Each checkbox will be associated with a database, and if multiple checkboxes are checked, it will pull up the requested database information. I just cant figure out how to loop the code to see which boxes are checked. Yes, the Diplay Trainer Name in Document area is messed up to, but I think it will give me less trouble then the loop.
Public Sub PrintClientList()
'declare variables and assign address to object variables
Dim balTrainer As Balloon, intReturnValue As Integer
Dim blnOpen As Boolean, strFileName As String, docClient As Document, tblClient As Table
Set balTrainer = Assistant.NewBalloon
Set docClient = Application.Documents("T11-WD-E1D2.doc")
'display assistant
Assistant.On = True
Assistant.Visible = True
'create and display balloon
With balTrainer
.Heading = "Trainers"
.Text = "Select Trainer(s)"
.Checkboxes(1).Text = "George"
.Checkboxes(2).Text = "Nora"
.Checkboxes(3).Text = "Pam"
.Button = msoButtonSetOkCancel
End With
intReturnValue = balTrainer.Show
'display trainer name in document
Select Case intReturnValue
Case 1
docClient.Paragraphs(6).Range.Text = _
"Trainer:" & vbTab & balTrainer.Checkboxes(1).Text & vbNewLine
Case 2
docClient.Paragraphs(6).Range.Text = _
"Trainer:" & vbTab & balTrainer.Checkboxes(2).Text & vbNewLine
Case 3
docClient.Paragraphs(6).Range.Text = _
"Trainer:" & vbTab & balTrainer.Checkboxes(3).Text & vbNewLine
End Select
'delete existing tables
For Each tblClient In docClient.Tables
tblClient.Delete
Next tblClient
'get the name of the Access database
With Application.Dialogs(wdDialogFileOpen)
.Name = "*.mdb"
blnOpen = .Display
strFileName = .Name
End With
If blnOpen = True And Right(strFileName, 4) = ".mdb" Then
'insert database information and display Print dialog box
Selection.EndKey unit:=wdStory
Selection.Range.InsertDatabase Format:=wdTableFormatClassic2, Style:=63, _
connection:="table client", DataSource:=strFileName
Application.Dialogs(wdDialogFilePrint).Show
End If
End Sub
I am trying to get this bit of code to loop through and see which checkboxes are checked and pull up the information associated with it. Each checkbox will be associated with a database, and if multiple checkboxes are checked, it will pull up the requested database information. I just cant figure out how to loop the code to see which boxes are checked. Yes, the Diplay Trainer Name in Document area is messed up to, but I think it will give me less trouble then the loop.
Public Sub PrintClientList()
'declare variables and assign address to object variables
Dim balTrainer As Balloon, intReturnValue As Integer
Dim blnOpen As Boolean, strFileName As String, docClient As Document, tblClient As Table
Set balTrainer = Assistant.NewBalloon
Set docClient = Application.Documents("T11-WD-E1D2.doc")
'display assistant
Assistant.On = True
Assistant.Visible = True
'create and display balloon
With balTrainer
.Heading = "Trainers"
.Text = "Select Trainer(s)"
.Checkboxes(1).Text = "George"
.Checkboxes(2).Text = "Nora"
.Checkboxes(3).Text = "Pam"
.Button = msoButtonSetOkCancel
End With
intReturnValue = balTrainer.Show
'display trainer name in document
Select Case intReturnValue
Case 1
docClient.Paragraphs(6).Range.Text = _
"Trainer:" & vbTab & balTrainer.Checkboxes(1).Text & vbNewLine
Case 2
docClient.Paragraphs(6).Range.Text = _
"Trainer:" & vbTab & balTrainer.Checkboxes(2).Text & vbNewLine
Case 3
docClient.Paragraphs(6).Range.Text = _
"Trainer:" & vbTab & balTrainer.Checkboxes(3).Text & vbNewLine
End Select
'delete existing tables
For Each tblClient In docClient.Tables
tblClient.Delete
Next tblClient
'get the name of the Access database
With Application.Dialogs(wdDialogFileOpen)
.Name = "*.mdb"
blnOpen = .Display
strFileName = .Name
End With
If blnOpen = True And Right(strFileName, 4) = ".mdb" Then
'insert database information and display Print dialog box
Selection.EndKey unit:=wdStory
Selection.Range.InsertDatabase Format:=wdTableFormatClassic2, Style:=63, _
connection:="table client", DataSource:=strFileName
Application.Dialogs(wdDialogFilePrint).Show
End If
End Sub