continuous forms, button visibility

A

Angi

My subform is continuous forms of contacts. On that form, I've created
a View button that should only be visible if that person has a home
office. The View works great! The problem I'm having is if one of the
contacts do not have a home office, it doesn't display the button for
anyone. If they all do, then it does. The HomeOffice field is a
yes/no. I'm pretty sure the problem is because I'm putting the code in
the FormLoad event and it's continuous so it doesn't look at each one
(?), but I don't know how to get it to look at each record if this is
the problem. I thought that's what I was doing by connecting the two
by ContactID. Sorry if this is confusing.

Here's my code:

Private Sub Form_Load()
If HomeOffice = True Then
Me!cmdHOffice.Visible = True
End If

End Sub

Thanks!
 
G

Guest

The Form Load is looking at the first record and making a decision for the
form based on the result. I dont think you can do what you want on a
continous form. The button will either show or not show.

If I am understanding this right what I usually do in this case is have a
toggle button in the footer and it will say "Contacts with Home Office" and
when you click on that button it will requery the form for contacts with a
home office and then click the toggle button and requery the form back to the
original query or something like that.

Note that the toggle button has a value of -1 when pressed in and 0 when not.


Hope this helps.


Steven
 
V

Van T. Dinh

What you see in the CtsForm is many instances of the same Control ("View"
button). All instances of the same Control will be either all visible or
all hidden depending on the Visible Property of the Control. You cannot have
some instances visible and some others hidden.
 
A

Angi

Steven,
Thank you for that explanation. I figured as much. I'm trying the
toggle button idea you suggested, but nothing happens. No error, but
no change either. Could you give me an idea of what I'm doing wrong?
I took out the .Value...didn't matter. TIA!

Private Sub tbShowHOffice_Click()
If tbShowHOffice.Value = -1 Then
DoCmd.RunSQL "SELECT ContactMain.*, ContactMain.HomeOffice FROM
ContactMain WHERE (((ContactMain.HomeOffice)=Yes));"
cmdHOffice.Visible = True
Me.Requery
Else
End If

End Sub
 
A

Angi

OK, i've changed the sql...don't know why. Thought it would make a
difference since it's a subform. It didn't. The problem is the button
doesn't "toggle". Even when I click it, it stays up. I've tried using
the help, but it is absolutely useless. I even created a text box that
is supposed to tell me what the value of the toggle btn is, but it
stays blank. Here's the new code:

Private Sub Toggle42_Click()
If Toggle42 = -1 Then
DoCmd.RunSQL "SELECT ContactMain.*, ContactMain.HomeOffice" _
& "FROM CompMain INNER JOIN ContactMain ON CompMain.CoID =
ContactMain.CoID" _
& "WHERE (((ContactMain.HomeOffice)=Yes));"
End If
End Sub
 
A

Anthony Ryan

Angi,

I have done something similar but not quiet.

I have a continuous form that highlights certain records when their
date is passed today's date.

The hightlighting is done by displaying text.
Add a TextBox to the detail section of your continuous form and in the
ControlSource, I have this: =IIf(DateDiff('d',[Date Task
Due],Now())>0,"Overdue","").

Only when that particular record is overdue the words are displayed,
the rest have empty text and therefore nothing is displayed.

This is only a thought, but you could then add a Click event to the
textbox to handle opening a form based on the words being diplayed

If Me!txtOverdueHighlight.Value <> "" Then
DoCmd.OpenForm "frm Form"
End If

I hope this helps

Anthony
 
F

Frazzled

Anthony,
Thank you very much for replying! It works great! I'm afraid i'm
gonna get blacklisted on this newsgroup with all my questions.

Thanks....again!
Angi
 

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