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

Check box question 2

Status
Not open for further replies.

goldygirl

Programmer
Jan 16, 2004
33
0
0
US
Dear Group,

I am straggling with check box logic. Here what I have…
I have a form with subform based on the query. Let’s say Form1, subform Form2 and based query name is Query1.

One of query field is a check box. This check box is responsible for free goods and located in the subform (Form2). I also have a text field in my subform width shows
$$ amount of the product.

Here is logic:
IF check box is checked, that means that the product is a free goods (I’d like to move the work “FREE” into text box,
Else
If the check box is not checked, that means the product must be charged (Qty * item cost).

The code I am using in VB is:

Private Sub Form_Load()

If Offer_Flag = -1 Then
Offer = "Free"
Else
Offer = [Offer_Qty] * [Prd_PrcD]
End If

End Sub

The problem is when the forms loads, it’s checks only for the first record in query (Query1). Another words, if the first record checked, it loads “FREE” for all records in the subform; if the first record is not checked it calculated text field based on the data in the first record of the query.

In what event I should use a logic to display the value (“FREE” or Item cost)??

Thanks for you feedbacks and help.

Regards,
Goldygirl

 
Hi - try putting the query in the offer field on the query itslef. offer:iif(check_box=-1,"Free",$$$$$)
This will perform the valuation on each record not for the entire form.

also you might want to enclose the iif with another iif checking if check bos ix null.
 
Thanks,

But I don't know how to define a new field with an expression the query….
 
Go into your query in design view then copy and paste the following line -

offer:iif(check_box=-1,"Free",$$$$$)


You will need to be sure to have whatever the checkbox field is as part of the query and change the name of the checkbox control to whatever it is that you actually have.


Hope this helps you.



Steve
 
Dear Steve,

I am trying to change my query, I am in design mode...
Where "offer:iif(check_box=-1,"Free",$$$$$)" should go?? In qry criteria or somewhere else????
 
Goldy,

You would place that into the "Field" section.

It takes the place of a field.

Chris
 
Chris,

I entered this expression onto the "field" and now I am getting an error msg "The exprssin you entered contains invalid index" :((
 
Goldy,

It needs to actually read

offer:iif(offer_flag=-1,"Free",$$$$$)

The check_box was refering to what you had named your check_box

Try that.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top