Show text if in warranty

g@v

Registered User.
Local time
Today, 13:55
Joined
Feb 14, 2005
Messages
14
Hi,

Would like some help after searching and having no luck I have a report and would like to have something that if in the warranty field I have drop down list of options to select for example 1 yr / 2yr / Non warranty and then if it's 1 yr or 2yr then a message will be inputted on to form saying "No charge under warranty" and when non warranty is selected on the form there will be a charge as out of warranty.

Thanks in advance for any pointers or tips :)
 
HI.

I think the easiest way to do this is to have a label on the form with your no charge message, then to make this visible or invisible according to your warranty setting.

You do this by putting a bit of code into the on current event of the form with something like this in it.

If me.warranty = 1yr then
me.message.visible = true
elseif me.warranty = 2 yr then
me.message.visible = true
else
me.message.visible = false
endif

you probably need to put this on the afterupdate event of the warranty checkbox as well.

you can also use the same technique to set the price to 0 if it is a warranty job.

I hope this helps, and is clear.

Sue
 
Hi,

Thanks for the fast reply, having trouble getting it working :( I created a label called warranty and in the build menu choose code and inputted...

Private Sub Label49_Click()
If me.Warranty = 1 Yr Warranty then
Me.message.Visible = True
elseif me.[Warranty] = 2 Yr Warranty then
Me.message.Visible = True
Else
Me.message.Visible = False
End If
End Sub

But how ever I do this it fails, would the above code put the words under warranty no charge so I can then print the report, sorry if something simple I use access for a while then go to not using for long time and now brain dead :rolleyes:

Thanks again for any tips.
 
ok let me have a stab at this

put these in a sepearate table
1 yr warranty
2 yr warranty
no warranty

but also have a text field as well so 1 yr warranty message no charge
no warranty chargable (or whatever )
then make a qry with these fields on it , make new combo on this qry

then on the after update properties of this combo have

this populate a field on your underlying table with the second field ie the field after warranty )

look at the attached sample (this is sloppy) and look at the customer form - this has a combo looking at a table and drags these values fromth e combo into the current form/table
g
 

Attachments

Code:
Private Sub Label49_Click()
Select Case Me.Warranty
    Case "1 Yr Warranty", "2 Yr Warranty"
        Me.YourMessageLabelName.Caption = "In Warranty"
    Case Else
        Me.YourMessageLabelName.Caption = "Out of Warranty"
End Sub

The problem with the other code that Sue provided was that the words had to be encapsulated within double-quotes. But this other code takes less and is cleaner. Now this is predicated on the actual value of the selection being "1 Yr Warranty" and not an id number. If it is the id number for the combo selection then change the case to Case 1, 2
 
if this is in a report - then you could follow my example and base the report on this or

rport properties have a field (text box) and in the report detail properioes select buidl code/ or event whatever get in to the code bit
now
if fieldx(not sure what the field will be) then " field on report ="chargable"
then else field =" "
 
having re-read this

my solution qry/table comob box I would have thought the easiest

allows for future amendements and differnet messages etc

also as its tabled based you get PK, rather than lists which can be a bit sloppy


this is the way I have done thing son a country table
list in a table 2nd column on the table has a warning message for certain countries , 3 column something else - you can then get creative and have flashing messages or in red for chargable whatever if theres no message then leave it blank - hell works fine for me - but then I try and simply everything whereever possible - so might not be the smartess solution

G
 
Hi,

You need to put the code on the afterupdate event of the warranty combo box.

You are not going to click the label as it might not be visible, so once it is hidden you can't get it back again.

You also need to put the criteria in comma's asd they are strings.

Try this

Private Sub warranty_Click()
If me.Warranty = "1 Yr Warranty" then
Me.message.Visible = True
elseif me.[Warranty] = "2 Yr Warranty" then
Me.message.Visible = True
Else
Me.message.Visible = False
End If
End Sub

if you can't get it to work send me a copy of the database and I'll try to sort it for you.

Sue
 
You also need to put the criteria in comma's asd they are strings.
You mean Quotation Marks " " not commas ,

...Me.message.Visible = True
...
...Me.message.Visible = False

Sue - If you have a label that has no background but words, there's no reason to make it visible and invisible and have the words static. Just use the .Caption property to set it to whatever you want for the particular item and if you want it invisible, set it's Caption to " ". If you have the background set to a different color then you will either want to set it's visible property or change the background color in code.
 
Wow many replies, Thanks to all that replied after a few hours of getting back in to access programming worked out what's needed (again big thanks to Bob exactly the sort of code I was after, and Sue thanks!)

Here is the code what I used...

Private Sub Label5_Click()
Select Case Me.Warranty
Case "1 Yr Warranty", "2 Yr Warranty", "Extended Warranty", "Repair Warranty"
Me.Label5.Caption = "In Warranty"
Case Else
Me.Label5.Caption = "Out of Warranty"
End Select
End Sub

Had to add the "End Select" at the End before "End Sub", Now I'll have a look at Sue's afterupdate as that would be better rather than clicking on.

Gary - Thanks also some nice code there which got my mind back in to access programming!
 

Users who are viewing this thread

Back
Top Bottom