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

If statement in Access 97 1

Status
Not open for further replies.

sabrina30

Programmer
Nov 2, 2000
31
US
I have a list field with Major, Minor and Priority in it. When Major is selected in the Alarm_type field I want a warning to show. Be it either the word Major to be in Red Bold or the Background in Red and/or a message shows warning that it is a Major Alarm.

A friend came up with a way to do it in Access 2000 using both background color and a picture of a button that is invisible unless Major is selected, but it doesn't work in Access 97. When he uses Event Procedure he goes into Visual Basic. When I use Event Procedure in Access 97 it takes me to Form Alarms: Class Module.

His formula goes like this:
Option compare Database

Private Sub Alarm_type_AfterUpdate ()
Call Form_Current

End Sub

Private Sub Form_Current()
Image1.Visible = True
[Alarm_type].BackColor = 16777215

If [Alarm_type] = "Major" Then
Image1.Picture = "c:\My documents\Major.jpg"
[Alarm_type].Backcolor = 255
Else
Image1.Visible = False

I can't get this to work in Access 97. Hope someone can help me with this.

s_wellman@mailcity.com
 
Hi Sabrina,
Place your form in design view. Double-click on the black square top left of the view. This will bring up the forms properties. Go to the event tab and find "On Current". Select "Event Procedure" and then click on the ellipse "..." button to its right. This will open up your forms class module, which is in fact VB of a slightly different sort. Paste below in between the "Form Current Sub" and "End Sub". (If there was anything already between, delete it…):

Image1.Visible = True
[Alarm_type].BackColor = 16777215
If [Alarm_type] = "Major" Then
Image1.Picture = "c:\My documents\Major.jpg"
[Alarm_type].Backcolor = 255
Else
Image1.Visible = False
End If



Now close up this "Module" and return to the form design view. Go to your control that Must be named "Alarm_type". Double-click on it to see its properties. Go to the events tab and find "After Update". as above, event procedure, ellipse button, and you're back in your module and it should have labeled up a sub called "Alarm_type_after_update" (or so). As before, clean out anything thats between, and then paste this in:

Form_Current

I do not know how your system would handle things if a control named "Image1" had no image file so you might check if in fact this file exists...we'll start with this: Make sure your image is named "Image1". Go to it!
Gord
ghubbell@total.net
 
Note: Access '97 does not have a separate VBA program like 2000 does its all inside Access '97
Try this if you are not getting in the correct VBA window.
Double click the Alarm_type box to bring up properties.
Click the ALL tab on the properties
then look down near the bottom of the list to find "after update" event.
click it, then click the down arrow and look for "Event Procedure" its the top option. then click the 3dots button and it should take you to the "Private Sub Alarm_type_AfterUpdate" sub
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
This worked for record 2...for some reason that's the only record it works on. By the way, I am using a .bmp image. Could that be the problem?
 
It's working now. I had made a mistake setting up the table. Thank y'all for your help.

Sabrina
 
Sabrina,
Using a .bmp should be fine. Is the image not working or the color change or both? Check if your image1 "Picture" property (double-click on the image when in design view, Format tab), actually contains a path to the image. Almost there! Gord
ghubbell@total.net
 
No...thank you. I expanded on your text to make the blackground change and such...works great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top