Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Jerusalem, Israel
    Thanked 0 Times in 0 Posts
    I have two forms: Main Form and KAF.

    On both of these forms I have the following fields: P and Country.
    KAF also has a checkbox (called KAF).

    The Main form is a continuous form, so I can't use a subform to show whether or not the checkbox for the corresponding record in KAF is checked.

    My idea was to display a label in the Main Form ONLY when the corresponding record in KAF has the checkbox checked. The thing is, BOTH of the fields (P and Country) need to match the record in the KAF form.

    I thought that what I could do is to make KAF open as a hidden form when the Main Form opens and then filter KAF so that it displays the record corresponding to the record on the Main Form that has the focus. Then I would need to run code like this to filter the hidden KAF form to match the current record in the Main Form:

      Dim stDocName As String
      Dim stLinkCriteria As String
      stDocName = "frm_KAF"
      stLinkCriteria = "[P]& [Country]=" & "'" & Me![P] & [Country] & "'"
      DoCmd.OpenForm stDocName, , , stLinkCriteria
    Then I would need to run code in the Main Form to display the label only if the checkbox is checked in KAF, like this:

    If Forms!frm_KAF.KAF = True Then
    Me.KAFLabel.visible = True
    End If
    1. I have not been able to filter KAF based on the record that has focus - how would I do that?
    2. This feels like a very round-about way to do this - is there an easier way?



  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Evergreen, CO, USA
    Thanked 58 Times in 58 Posts
    Why not use a similar data source for both forms? Create an expression something like this for the main form:
    KAFTrue: IIF([KAF],"Text for the pseudo label goes here",Null)
    Then instead of using a Label, use a Text Box with no attached Label and set the data source for the Text Box to KAFTrue.

    Assuming you do want to take the approach you attempted, you should be able to use the OnCurrent event to do the filtering and turn the KAFLabel on and off, although you may encounter timing issues and need to do some Refreshes or Requeries.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts