Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

Checkboxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Karl - 11 Dec 2005 10:21 GMT
Hi all,

I have a form with a junction table as the datasource.

The form has three checkboxes.
chkInactive - an Active / Inactive checkbox for the main record
chkProj - an Active / Inactivecheckbox for one of the junction fields
chkAct - an cActive / Inactiveheckbox for the other field.

If either of chkProj or chkAct is ticked, then chkInvalid should be
ticked. This part seems to work OK. ( see code below )
When I scroll through the records in form view, the records where
chkInactive are marked inactive from the either chkProj or chkAct, keep
updating each time I view them.

The OnCurrent event is as follows:

If Me.chkProj = -1 OR Me.chkAct = -1 Then
   If Not IsNull(Me.chkInactive.Value) Then
      Me.chkInactive.Value = -1
        Else: Me.Inactive.Value = Null
    End If
End If

Is this code causing the main record to keep updating itself on
viewing?

Thanks in advance

Karl
Jeff Smith - 11 Dec 2005 10:34 GMT
> Hi all,
>
[quoted text clipped - 26 lines]
>
> Karl

Hi Karl

If the chkProj and the chkAct are bound to the form then the check boxes can
only be ticked or unticked (True or False), they can not be null. Try:
If Me.chkProj = -1 OR Me.chkAct = -1 Then
   Me.chkInactive = -1
Else
   Me.chkInactive = 0
End If

HTH
Jeff
Karl - 11 Dec 2005 10:43 GMT
Hi Jeff

Thanks for that.

oops.

I had Me.chkIinactive=0. Thought setting to Null may help and forgot to
set it back before posting.

Just to clarify, if I comment out the above code, LastUpdated time
stays as it should when viewed. Uncomment the code and the time resets
each time it is viewed.

Karl
Allen Browne - 11 Dec 2005 11:47 GMT
Yes, Karl. Assigning a value to a bound control in Form_Current updates it
every time you visit the record.

Perhaps you don't need to store chkInactive, so you could just use a text
box bound to:
   =((chkProj) OR (chkAct))

Or perhaps you could assign the value only if it's not already set
correctly:

Private Sub Form_Current()
   Dim bInactive
   bInactive  = Nz(((Me.chkProj.Value) OR (Me.chkAct.Value)), False)
   With Me.chkInactive
       If .Value <> bInactive Then
           .Value = bInactive
       End If
   End With
End Sub

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Hi Jeff
>
[quoted text clipped - 10 lines]
>
> Karl
Karl - 11 Dec 2005 19:41 GMT
Hi Allen,

As you suggested, it appears that I was updating the record each visit.

I found the second approach to work quite well.

Thanks a lot

Karl
> Yes, Karl. Assigning a value to a bound control in Form_Current updates it
> every time you visit the record.
[quoted text clipped - 35 lines]
> >
> > Karl
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.