How do I hide controls that have no info, on a form based on a qu.

G

Guest

I generated a form that reports material testing results, based on material
number, I would like the testing parameters without data to be invisible, is
this possible?
 
G

Guest

Hi, Schenk.

In general, one makes a form control invisible by setting its Visible
property to False, e.g.:

Me![SpecificGravity].Visible = False

so to set all controls without data in them to False, you could put the
following code in the form's On Current event:

Dim ctl As Control
For Each ctl In Me.Controls
If IsNull(ctl.Value) Then
ctl.Visible = False
Else
ctl.Visible = True
End If
Next

but I have the following questions:

- How would you add new records? A new record would have all of its
controls except a new autonumber primary key Null.
- It seems that there is a one-to-many relationship between a product batch
and the properties which are tested:

Batch
-----------
BatchID PK
MaterialID Number (FK to Materials)
TestDate Date/Time
....

BatchTests
-------------
BatchTestID PK
BatchID FK to Batch
TestID FK to Tests
Result Single

If this is the case, you might consider a main form based on Batch with an
embedded subform based on BatchTests, linked on BatchID. Then only the tests
for that batch would display.

Hope that helps.

Sprinks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top