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

setting an unbound checkbox on report 1

Status
Not open for further replies.

RnRExpress

Technical User
Oct 24, 2004
53
US
I have a report, where there is an unbound checkbox. I would like the report, when run, to autmatically place a check mark in ths bax (i.e. be true) IF the record on the form has a specific text box set to one specific value.

My form has a text box called "Location" on it that has a two-item list. They are simply "IN" and "OUT". I would like it so when I run this report, any record on the form that has this "Location" set to "Out", this unbound check box on the report is checked, or true.

Again, I am a very much a beginner so any help is extremely appreciated.

Richard
 
In the report Format section try:

If Me.Location = "Out" Then Me.CheckboxName = True

Change "CheckboxName" for the name of the chockbox on the form

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
Trendsetter,

thanks. that worked like a charm.

Along that same line, is there a way I can reuse your code so that on another unbound checkbox, I can have it be true (checked) if another field on the form is empty?

In other words, I would like to check a date field. If the field is empty, I wish the box to remain unchecked. But if a date is entered, I would like the box checked.
 
On other thing I am trying too, is to check for content of a first name field.

If this field contains "OTC" then I want a checkbox (another unbound one) to be checked. Otherwise, I want the checkbox to be false, or blank.

with the code above, I can get the checkboxes checked (or true). But on those where the checkmark isn't there, the box is greyed, instead of showing a true "False" state.

I tried:

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)

If Me.Customer_First_Name = "OTC" Then Me.Check49 = True
Else
Me.Check49 = False
End If
End Sub

Obviously this isn't working. (which is not surprise with my access programming expertise.) If anyone can shed some light for me, i'd appreciate it.
 
OOps, time to backtrack.

Using the code i originally got back from Trendsetter:

If Me.Location = "Out" Then Me.CheckboxName = True

The checkbox I am using is now always true, regardles if the Location is set to. I have this code in the Detal_Format events so I think I have it in the right place.
 
You may try this:
Me.CheckboxName = (Me.Location = "Out")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Put the code in the Report_Format section.

Re your date field:
If IsNull(Me.DateFieldName) Then Me.CheckboxName = False

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
And for the date field:
Me.CheckboxName = Not (IsNull(Me.DateFieldName))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks guys.

One alst question, is can I put all these into the same Detail_Format section? I seem to get an error when I have two things inside the Detail_Format section.
 
get an error
Any chance you could post the error message and the relevant portion of code ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
The error I get is:

The expression On Format you entered as the event property setting produced the following error: Ambiguous name detected: Detail_Format.
* The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
* There may have been an error evaluating the unction, event or macro.

The code I have is:

Option Compare Database
-------------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Check43 = (Me.Repair_Location = "NRC")
End Sub
-------------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Check45 = Not (IsNull(Me.[Date Loaner Issued]))
End Sub


The error goes away as long as I remove one of these sections. And it doesnt matter which one, as long as I remove one.
 
Have you tried this ?
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Check43 = (Me.Repair_Location = "NRC")
Me.Check45 = Not (IsNull(Me.[Date Loaner Issued]))
End Sub


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

You are nothing less than awesome. I thought I tried that but for some reason, cutting and pasting your code worked.

Thanks again!!
Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top