Results 1 to 8 of 8
  1. #1
    Join Date
    May 2003
    Posts
    32

    Unanswered: Need help with expression

    Is it possible to have a conditional expression between a main form and a subform? I am trying to compare a value entered into a subform against a value in the main form. I can't seem to get it to work. Any suggestions?

    Forms![Incoming Entry Form]![Incoming Subform]![ODMin] < Forms![Incoming Entry Form]![OD Min]

  2. #2
    Join Date
    Dec 2002
    Posts
    60

    Re: Need help with expression

    Try:
    Forms![Incoming Entry Form]![Subform Obj].Form.[ODMin] <...

    Where [Subform Obj] is the object on [Incoming Entry Form] that contains the subform.

    You can't refer directly to the subform by name, have to refer to the object the subform has been placed in.

  3. #3
    Join Date
    May 2003
    Posts
    32

    Re: Need help with expression

    Where should I use this code? I have been trying it in a macro but it doesn't work. I get an error message that reads: The object you referenced in VB procedure as an OLE object isn't an OLE object.

    I am a little confused on this matter....


    Originally posted by bc301
    Try:
    Forms![Incoming Entry Form]![Subform Obj].Form.[ODMin] <...

    Where [Subform Obj] is the object on [Incoming Entry Form] that contains the subform.

    You can't refer directly to the subform by name, have to refer to the object the subform has been placed in.

  4. #4
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    when do you want the evaluation to be run?

    It is hard to determine where to place the code for you

    do you want the comparison of the items after you update a field, go to a specific record, and what do want to happen based on the results of the comparison?

  5. #5
    Join Date
    May 2003
    Posts
    32

    Still confused

    Sorry for the delay. I am still working on this but I my priorities changed so this is the first chance back at it.

    I am entering data in the subform that I want to compare to a specification in the main form.

    Essentially, it is this:

    IF ODMin on the Subform is < OD Min on the Main Form then give an error message.

    I want the error message as soon as I have entered the data on the subform.

    Thanks for your help.


    Originally posted by axsprog
    when do you want the evaluation to be run?

    It is hard to determine where to place the code for you

    do you want the comparison of the items after you update a field, go to a specific record, and what do want to happen based on the results of the comparison?

  6. #6
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    behind the afterupdate event of the field on the subform use this type of code

    if me![od min] < me.parent[od min] then

    do whatever

    end if

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    how about in the beforeupdate event
    Code:
    if ODMin.Value < Forms![Incoming Entry Form].[od min] then
    msgbox ODMin.value & " is below the minimum allowed", vbinformation, "User Error"
    cancel = true
    endif
    why oh why oh why all those spaces in field/form/whatever names?
    IncomingEntryForm is just as easy to read, and
    frmIncomingEntry is even better

    izy

  8. #8
    Join Date
    May 2003
    Posts
    32
    Thank you, izy, it worked!

    Originally posted by izyrider
    how about in the beforeupdate event
    Code:
    if ODMin.Value < Forms![Incoming Entry Form].[od min] then
    msgbox ODMin.value & " is below the minimum allowed", vbinformation, "User Error"
    cancel = true
    endif
    why oh why oh why all those spaces in field/form/whatever names?
    IncomingEntryForm is just as easy to read, and
    frmIncomingEntry is even better

    izy

Posting Permissions

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