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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox changed to text

Status
Not open for further replies.

niteraven

Technical User
Oct 26, 2006
92
US
Good Day All,

I have a report that is based on a form. THe form has a series of checkboxes for describing the type of warranty problem. On the report i have some if statements that check to see if the checkbox is checked then changes to text. But now the manager wants to be able to have two or more checkboxes checked and i cannot get any of the code to work. Any ideas are most welcome.

Here is the current code:
<code>
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If warchkbx.Value = True Then
Me!warrantyreq.Value = "WARRANTY WAS REQUESTED BY CUSTOMER"
End If
If noprob.Value = True Then
Me!warreason.Value = "NO PROBLEM FOUND"
End If
If probnotdue.Value = True Then
Me!warreason.Value = "PROBLEM NOT DUE TO MANUFACTURING DEFECT"
End If
If priorrepair.Value = True Then
Me!warreason.Value = "PROBLEM NOT ASSOCIATED WITH PRIOR REPAIR"
End If
If expiredwar.Value = True Then
Me!warreason.Value = "WARRANTY PERIOD HAS EXPIRED"
End If
If otherwar.Value = True Then
Me!warreason.Value = "OTHER"
End If
End Sub
</code>

I have replaced the if statement with this code, it did not work:
<code>
If expiredwar.Value = True Then
Me!warreason.Value = me!warreason + " WARRANTY PERIOD HAS EXPIRED"
End If

</code>

Any thoughts?
Raven
 
Hi nit,

Firstly, you can say:
[tt]
IF warchkbx THEN
[/tt]
which literally means: IF warchkbx is true THEN.

This makes it simpler to combine IF statements, e.g.:
[tt]
IF ((warchkbx) AND (whateverotherchkbox)) then
warreason = "whatever text " & " and " & " whatever other text"
ENDIF
[/tt]

ATB

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
You can try code like
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If warchkbx = True Then
       Me!warrantyreq = "WARRANTY WAS REQUESTED BY CUSTOMER"
    End If
    If noprob = True Then
       Me!warreason = "NO PROBLEM FOUND AND "
    End If
    If probnotdue = True Then
       Me!warreason = Me!warreason & "PROBLEM NOT DUE TO MANUFACTURING DEFECT AND "
    End If
    If priorrepair = True Then
       Me!warreason = Me!warreason & "PROBLEM NOT ASSOCIATED WITH PRIOR REPAIR AND "
    End If
    If expiredwar = True Then
       Me!warreason = Me!warreason & "WARRANTY PERIOD HAS EXPIRED AND "
    End If
    If otherwar = True Then
       Me!warreason = Me!warreason & "OTHER AND "
    End If
    If Len(Me!WarReason) > 5 Then
        Me.WarReason = Left(Me!warreason, Len(Me!warreason) -4)
    End If
End Sub

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top