New form/old table control visibility

G

GD

I'm designing a new form for an existing table. I need to program certain
areas to be visible or invisible, based on a check box or text box within the
form. The problem is that if I use the AfterUpdate event, the existing
records don't act accordingly (since their controls/data were previously
updated). Is there another event I can use that depends on whether or not a
box is empty or filled? Or can I programmatically refer back to the table
field?

Currently my code looks like this:

Private Sub chkPaybackApproved_AfterUpdate()
If Me.chkPaybackApproved = True Then
Me.cboApprBy.Visible = True
Else
Me.cboApprBy.Visible = False
End If

End Sub

Private Sub Form_Current()
If Me.chkPaybackApproved = True Then
Me.cboApprBy.Visible = True
Else
Me.cboApprBy.Visible = False
End If

End Sub

Again, this works fine for new records. But existing ones stay hidden.

Thanks for your time!!
 
S

strive4peace

to set things according to existing records, the Current event should be
the one to use...

and you may want to test for Me.NewRecord=true in the Current event
since it won't have a value to compare

if a control influences something, then the control AfterUpdate event
should also be used -- so you seem to be doing everything right

.... what is the problem?

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
G

GD

The problem is that the existing records appear in the form with check boxes
checked, but the areas that are supposed to become visible don't, unless the
check box is unchecked, then checked again (i.e. updated).

I don't see a Current event for anything but the form. Should I be entering
my code in this event only? If so can you give me a generic example?

Thanks!!
 
S

strive4peace

The Current event is triggered when you move to a different record --
and it is at the form level. If the form is not bound to a
RecordSource, this event does not happen.

Can you describe the data used for your form and subforms?

ie:
Main form:
RecordSource? (what is the tablename or SQL statement?)

subform1:
Name?
LinkMasterFields?
LinkChildFields?
RecordSource?

etc...

what are the sections that you are hiding and showing and why?

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 

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