Dalvoron
Jul 19 2007, 09:45 AM
Greetings, thought I'd let you know, this is my first post.
My problem is this: I have to create a form where fields (or controls) only appear for relevant records, and really have no idea where to start.
If that wasn't specific enough: We are tracking the discharges that certain companies are making to rivers. We have licensed them to dishcarge if the limit the concentration of certain characteristics (nutrients, metals etc.). A few of these licenses are quite old, and only limit one or two characteristics, and some characteristics are only relevant to certain companies (for example, discharges from quarries are limited in the amount of metals discharged, restaurants may be limited be the amount of grease/fat they discharge, petrol stations may be limited by organic compounds etc.). I have to create a form where irrelevant fields (controls) are not displayed on their record.
I should mention that I have no experience with coding in Access, so would prefer not to have to use it. If it is necessary however, could you please explain where the code has to go? Also, Access 2000 is available to me, so if it is possible there, and not in 97, it's no problem.
Thanks in advance.
HiTechCoach
Jul 19 2007, 10:02 AM
Welcome to Utter Access!
I don't now fo a way to do this without using VBA code.
You will need to use some field as the "flag" to control which field are relevant
I would use the form's
On Current event with something like:
CODE
' using a date field
If Me.[YourdateControl] < #1/1/2007# ' some cut off date
' Not relevant
Me.[YourControl1].visible = False
Else
' relevant
Me.[YourControl1].visible = True
End if
Hope this helps ...
Edited by: HiTechCoach on Thu Jul 19 11:20:22 EDT 2007.
Edited by: HiTechCoach on Thu Jul 19 11:21:03 EDT 2007.
Dalvoron
Jul 19 2007, 10:10 AM
Thanks for the welcome, just 2 more quick questions:
1. I don't have a date or anything, I was hoping that an empty field, or a 0, or something would be sufficient criteria. I know I can filter the form for certain things, and was hoping to make a filter to exclude certain things (without simply creating hundreds of OR pages in the filter of course)
2. As I said, I have no experience with code, so...... if I were to use that code, where would I put it?
I'm finished work for the day, so I won't be able to test out any suggestions, but I'll keep monitoring overnight, and try them in the morning.
HiTechCoach
Jul 19 2007, 10:19 AM
Answer 1:
Try something like:
CODE
If Me.[YourFlagControl] = 0 or IsNull(Me.[YourFlagControl]) ' if flag is Zero or Null then not relevant
' Not relevant
Me.[YourControl1].visible = False
Else
' relevant
Me.[YourControl1].visible = True
End if
Answer #2:
As stated in my previous post:
I would use the form's
On Current event with ...
Edited by: HiTechCoach on Thu Jul 19 11:21:40 EDT 2007.
Dalvoron
Jul 20 2007, 04:16 AM
Well I tried it out with a new control, simply called "control", using the following:
CODE
Private Sub OnCurrent()
If Me.[Control] = 0 Then
' Not relevant
Me.[Control].Visible = False
Else
' relevant
Me.[Control].Visible = True
End If
End Sub
And it didn't seem to have any effect at all, any thoughts amigos?