Where statement not working on OpenForm when writing a new record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reginaldmerritt
    New Member
    • Nov 2006
    • 201

    Where statement not working on OpenForm when writing a new record

    Hi,

    I have 1 table and 2 forms. 1 form for entering main data, i.e. Primary Key, Name, Address, etc. Another form for entering extra information if required.

    The first form has a button to open the second form. This works perfectly for any current records but doesn't work for new records. Instead the second form opens as a new record itself.

    The where statment only seems to work if the record is not new ????? I've been searching for hours and can't find this problem any where else.

    The code i'm using to open the second form is
    Code:
    DoCmd.OpenForm "AdditionalInformation",acNormal,,"[FormNumber] = '" & Me.FormNumber & "'"
    (FormNumber is a primary key)

    Any ideas on what could be happening here????

    Thanks.
  • reginaldmerritt
    New Member
    • Nov 2006
    • 201

    #2
    I guess everyone is a stumped at this as me.

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      My guess is that the new record on the first form hasn't been saved when you move to the second form. Immediately before the line of code you posted place this line:

      If Me.Dirty Then Me.Dirty = False

      and see if that doesn't do the trick!

      Linq ;0)>

      Comment

      • reginaldmerritt
        New Member
        • Nov 2006
        • 201

        #4
        Worked a treat, well done.
        Thanks

        Comment

        • missinglinq
          Recognized Expert Specialist
          • Nov 2006
          • 3533

          #5
          Glad we could help!

          Linq ;0)>

          Comment

          Working...