A
Aviator
I have a DB that has a look up field for aircraft type that gets info from a
small seperate DB that contains many aircraft types. The main DB also has 25
check box fields that split an aircraft interior info different parts. When a
job is done, the work order number(primary key) is entered, along with the
aircraft type. The areas worked on during the job are checked, there could be
just one or as many as 25. I have a Form created that I want to use to obtain
the parameters for the report I created. The form contains one combo
box(Aircraft Type) and the 25 check boxes. I user would select the aircraft
type and one or many check boxes to return the work orders that were of that
aircraft type and work was completed in those specified areas. I have the
check box part working fine, have been unable to get the combo box to only
return results of that aircarft type. No errors, using access 2003. The
following is the code used on the form. Aly help would be greatly
appreciated.
Private Sub OK_Click()
Dim strWhere As String
Dim ctl As Control
strWhere = "" 'initialize the where clause
For Each ctl In Me.Controls 'loop through all controls on form
'find the check boxes
If ctl.ControlType = acCheckBox Then
'find the true check boxes
If ctl.Value = True Then
'add to the where clause
strWhere = strWhere & "[" & ctl.Tag & "] or "
End If
End If
Next
If Len(strWhere) > 1 Then
'remove the last " or " from the where clause
strWhere = Left(strWhere, Len(strWhere) - 4)
Debug.Print "strWhere: " & strWhere
End If
'the final strWhere might look like
'[Airstairs/Entrance] or [Carpet] or [Cockpit Items] or [Complete
Refurbishment] or [Cup Holders] or [Curtain] or [Divan] or [Dye Job] or
[Entertainment] or [Galley] or [Headliner] or [Lavatory] or [Lighting] or
[Loncoin] or [Lower Side Walls] or [Painting] or [Repairs] or [Runner] or
[Seat Belts] or [Seats] or
or [Telephone] or [Various/Miscellaneous]
or [Veneer] or [Windowline]
'open the report based on the checked boxes
DoCmd.OpenReport "Type and Work Report", acViewPreview, , strWhere
End Sub
Private Sub Close_Click()
DoCmd.Close 'Close Form
End Sub
small seperate DB that contains many aircraft types. The main DB also has 25
check box fields that split an aircraft interior info different parts. When a
job is done, the work order number(primary key) is entered, along with the
aircraft type. The areas worked on during the job are checked, there could be
just one or as many as 25. I have a Form created that I want to use to obtain
the parameters for the report I created. The form contains one combo
box(Aircraft Type) and the 25 check boxes. I user would select the aircraft
type and one or many check boxes to return the work orders that were of that
aircraft type and work was completed in those specified areas. I have the
check box part working fine, have been unable to get the combo box to only
return results of that aircarft type. No errors, using access 2003. The
following is the code used on the form. Aly help would be greatly
appreciated.
Private Sub OK_Click()
Dim strWhere As String
Dim ctl As Control
strWhere = "" 'initialize the where clause
For Each ctl In Me.Controls 'loop through all controls on form
'find the check boxes
If ctl.ControlType = acCheckBox Then
'find the true check boxes
If ctl.Value = True Then
'add to the where clause
strWhere = strWhere & "[" & ctl.Tag & "] or "
End If
End If
Next
If Len(strWhere) > 1 Then
'remove the last " or " from the where clause
strWhere = Left(strWhere, Len(strWhere) - 4)
Debug.Print "strWhere: " & strWhere
End If
'the final strWhere might look like
'[Airstairs/Entrance] or [Carpet] or [Cockpit Items] or [Complete
Refurbishment] or [Cup Holders] or [Curtain] or [Divan] or [Dye Job] or
[Entertainment] or [Galley] or [Headliner] or [Lavatory] or [Lighting] or
[Loncoin] or [Lower Side Walls] or [Painting] or [Repairs] or [Runner] or
[Seat Belts] or [Seats] or
or [Veneer] or [Windowline]
'open the report based on the checked boxes
DoCmd.OpenReport "Type and Work Report", acViewPreview, , strWhere
End Sub
Private Sub Close_Click()
DoCmd.Close 'Close Form
End Sub